我想使用.devcontainer,这样我的团队成员就可以有一个相同的设置。我不能让它工作。这是Dockerfile的样子:
FROM ubuntu:focal
## Inspiration from https://stackoverflow.com/questions/67680726/installing-haskells-cabal-or-ghcup-inside-a-dockerfile-wont-work
ENV TZ=Europe/Berlin
ARG USERNAME=vscode
ENV USERNAME=${USERNAME} \
USER_UID=1000 \
USER_GID=1000 \
DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF8 \
WDIR=/home/${USERNAME}
# install dependencies
RUN \
apt-get update -y && \
apt-get install -y --no-install-recommends \
curl \
libnuma-dev \
zlib1g-dev \
libgmp-dev \
libgmp10 \
git \
wget \
lsb-release \
software-properties-common \
gnupg2 \
apt-transport-https \
gcc \
autoconf \
automake \
build-essential
# install gpg keys
ARG GPG_KEY=BA3CBA3FFE22B574
RUN gpg --batch --keyserver keys.openpgp.org --recv-keys $GPG_KEY
# install ghcup
RUN \
curl https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup > /usr/bin/ghcup && \
chmod +x /usr/bin/ghcup && \
ghcup config set gpg-setting GPGLax
ARG GHC=8.10.7
ARG CABAL=3.10.1.0
ARG HLS=2.0.0.1
ARG STACK=2.11.1
# install GHC and cabal
RUN ghcup -v install ghc --isolate /usr/local --force ${GHC}
RUN ghcup -v install cabal --isolate /usr/local/bin --force ${CABAL}
RUN ghcup -v install stack --isolate /usr/local/bin --force ${STACK}
RUN ghcup -v install hls --isolate /usr/local/bin --force ${HLS}
RUN groupadd --gid $USER_GID $USERNAME && \
useradd -ms /bin/bash -K MAIL_DIR=/dev/null --uid $USER_UID --gid $USER_GID -m $USERNAME && \
mkdir -p /etc/sudoers.d && \
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME
USER ${USER_UID}:${USER_GID}
WORKDIR ${WDIR}
ENV DEBIAN_FRONTEND=dialog
ENTRYPOINT ["/bin/bash"]
字符串
不幸的是,路径似乎有问题:Haskell扩展给出了以下输出:
2023-07-29 05:28:48.3350000 [client] ERROR Error executing 'ghcup --no-verbose whereis hls 2.0.0.1' with error code 30
2023-07-29 05:28:48.3350000 [client] ERROR stderr: [1m[ Error ][0m []8;;https://errors.haskell.org/messages/GHCup-00130\GHCup-00130]8;;\] The version 2.0.0.1 of the tool hls is not installed.
2023-07-29 05:28:48.3520000 [client] ERROR Error executing 'ghcup --no-verbose whereis cabal 3.10.1.0' with error code 30
2023-07-29 05:28:48.3520000 [client] ERROR stderr: [1m[ Error ][0m []8;;https://errors.haskell.org/messages/GHCup-00130\GHCup-00130]8;;\] The version 3.10.1.0 of the tool cabal is not installed.
2023-07-29 05:28:48.3690000 [client] ERROR Error executing 'ghcup --no-verbose whereis stack 2.11.1' with error code 30
2023-07-29 05:28:48.3690000 [client] ERROR stderr: [1m[ Error ][0m []8;;https://errors.haskell.org/messages/GHCup-00130\GHCup-00130]8;;\] The version 2.11.1 of the tool stack is not installed.
型
如果我在vscode中打开一个终端,我可以看到一切都安装正确,并且它在我的路径中:
vscode@c983ad0b50ef:/workspaces/Ampersand$ which stack
/usr/local/bin/stack
vscode@c983ad0b50ef:/workspaces/Ampersand$ whoami
vscode
vscode@c983ad0b50ef:/workspaces/Ampersand$ echo $PATH
/vscode/vscode-server/bin/linux-x64/2ccd690cbff1569e4a83d7c43d45101f817401dc/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
vscode@c983ad0b50ef:/workspaces/Ampersand$
型
我将非常感谢任何建议。
1条答案
按热度按时间xhv8bpkk1#
我不知道你的具体设置有什么问题,但你也可以使用devcontainer features,而不必构建自己的Docker镜像。有一个devcontainer feature可以用来安装Haskell。你也应该能够在
devcontainer.json
中配置environment variables。我自己也有这样一个setup来设置一个GitHub代码空间。