haskell - 构建docker镜像时堆栈GHCJS项目初始化错误

标签 haskell docker dockerfile haskell-stack ghcjs

我正在尝试创建一个 docker 镜像作为 GHCJS 开发环境。

我在 Dockerfile 的这一行上收到一个错误,该行是使用堆栈初始化 GHCJS 模板项目:

运行 stack new helloWorld ghcjs

整个 Dockerfile 是:

FROM debian:latest

#update
RUN apt-get update
#install apt-utils and emacs
RUN apt-get install -y apt-utils emacs-nox
#install ghcjs dependencies
RUN apt-get install -y curl git libtinfo-dev alex happy nodejs-legacy nodejs
#install stack
RUN curl -sSL https://get.haskellstack.org/ | sh
#add stack to path
RUN echo "PATH=$PATH:/usr/local/bin/stack:/root/.local/bin" >> /root/.profile
#create and change into project directory
RUN mkdir /root/ghcjs/ && cd /root/ghcjs/
#initialize ghcjs project
RUN stack new helloWorld ghcjs
#add stack.yaml
ADD stack.yaml /root/ghcjs/helloWorld/
#install ghcjs
RUN stack setup

输出和错误是:

Downloading template "ghcjs" to create project "helloWorld" in helloWorld/ ...

The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in /root/.stack/config.yaml, like this:
templates:
  params:
    author-email: value
    author-name: value
    category: value
    copyright: value
    github-username: value
Or you can pass each one as parameters like this:
stack new helloWorld ghcjs -p "author-email:value" -p "author-name:value" -p "category:value" -p "copyright:value" -p "github-username:value"

Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- helloWorld/helloWorld.cabal

Selecting the best among 11 snapshots...

Downloading lts-9.12 build plan ...
Downloaded lts-9.12 build plan.
Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcomplete.com/) ...
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading root
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading timestamp
Downloading snapshot
Downloading mirrors
Cannot update index (no local copy)
Downloading index
Updated package list downloaded
Populating index cache ...
Populated index cache.
* Partially matches lts-9.12
    ghcjs-base not found
        - helloWorld requires -any

Downloading nightly-2017-11-09 build plan ...
Downloaded nightly-2017-11-09 build plan.
* Partially matches nightly-2017-11-09
    ghcjs-base not found
        - helloWorld requires -any

Downloading lts-8.24 build plan ...
Downloaded lts-8.24 build plan.
* Partially matches lts-8.24
    ghcjs-base not found
        - helloWorld requires -any

Downloading lts-7.24 build plan ...
Downloaded lts-7.24 build plan.
* Partially matches lts-7.24
    ghcjs-base not found
        - helloWorld requires -any

Downloading lts-6.35 build plan ...
Downloaded lts-6.35 build plan.
* Partially matches lts-6.35
    ghcjs-base not found
        - helloWorld requires -any

Downloading lts-5.18 build plan ...
Downloaded lts-5.18 build plan.
* Partially matches lts-5.18
    ghcjs-base not found
        - helloWorld requires -any

Downloading lts-4.2 build plan ...
Downloaded lts-4.2 build plan.
* Partially matches lts-4.2
    ghcjs-base not found
        - helloWorld requires -any

Downloading lts-3.22 build plan ...
Downloaded lts-3.22 build plan.
* Partially matches lts-3.22
    ghcjs-base not found
        - helloWorld requires -any

Downloading lts-2.22 build plan ...
Downloaded lts-2.22 build plan.
* Partially matches lts-2.22
    ghcjs-base not found
        - helloWorld requires -any

Downloading lts-1.15 build plan ...
Downloaded lts-1.15 build plan.
* Partially matches lts-1.15
    ghcjs-base not found
        - helloWorld requires -any

Downloading lts-0.7 build plan ...
Downloaded lts-0.7 build plan.
* Partially matches lts-0.7
    ghcjs-base not found
        - helloWorld requires -any

Selected resolver: lts-9.12
Resolver 'lts-9.12' does not have all the packages to match your requirements.
    ghcjs-base not found
        - helloWorld requires -any

This may be resolved by:
    - Using '--solver' to ask cabal-install to generate extra-deps, atop the chosen snapshot.
    - Using '--omit-packages to exclude mismatching package(s).
    - Using '--resolver' to specify a matching snapshot/resolver

The command '/bin/sh -c stack new helloWorld ghcjs' returned a non-zero code: 1

编辑:

这是编辑后的 ​​Dockerfile,以考虑@SamuraiJack 评论。它现在已经解决了这个问题中提到的问题。

FROM debian:latest

#update
RUN apt-get update
#install apt-utils and emacs
RUN apt-get install -y apt-utils emacs-nox
#install ghcjs dependencies
RUN apt-get install -y curl git libtinfo-dev alex happy nodejs-legacy nodejs
#install stack
RUN curl -sSL https://get.haskellstack.org/ | sh
#add stack to path
RUN echo "PATH=$PATH:/usr/local/bin/stack:/root/.local/bin" >> /root/.profile
#create and change into project directory
RUN mkdir /home/ghcjs/ && cd /home/ghcjs/ && \
#initialize ghc project
stack new helloWorld
#add stack.yaml
ADD stack.yaml /home/ghcjs/helloWorld/
#install ghcjs
RUN cd /home/ghcjs/helloWorld/ && \
stack setup

最佳答案

在使用它创建新项目之前需要安装 ghcjs(ghcjs-base 将成为 ghcjs 安装的一部分)。

检查 herehere

关于haskell - 构建docker镜像时堆栈GHCJS项目初始化错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47209331/

相关文章:

docker - 使用 ENV 变量在 Dockerfile 中创建目录

haskell - 相互引用的默认类型实例

haskell - 实现 `Applicative (Free f)`

docker - Windows 容器无法访问互联网,但 Linux 容器可以 - 在主机上激活 VPN 客户端

Docker 不释放端口

linux - 在 Dockerfile 中安装软件并设置环境变量

haskell - 为什么 `putStrLn getLine` 不起作用?

haskell - 将嵌套类型转换为 monad 转换器堆栈

bash - docker 日志和缓冲输出

linux - 在 Alpine docker 中安装软件包