运行 emacs intero-mode with stack docker 集成

Running emacs intero-mode with stack docker integration

我正在尝试在启用了 docker 集成的堆栈项目中使用内部模式。因此其 stack.yml 包含:

docker:
  enable: true
  image: my-project/build:lts-11.9

尽管如此,当我打开项目中的任何 .hs 文件时,intero-mode 尝试安装 intero 可执行文件但失败了。在 Messages 缓冲区中报告:

Installed successfully! Starting Intero in a moment ...
Booting up intero ...
Problem with Intero!
Reading Haskell configuration failed with exit code 1 and output:
get-cabal-configuration.hs: /home/jesuspc/.nix-profile/bin/hpack: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)

我得到了内部模式的错误屏幕:

...
The process ended. Here is the reason that Emacs gives us:

exited abnormally with code 1

For troubleshooting purposes, here are the arguments used to launch intero:

stack ghci --with-ghc /home/jesuspc/.stack/compiler-tools/x86_64-linux-dke094d5208e8a802cb369cecdad3049ae/ghc-8.2.2/bin/intero "--docker-run-args=--interactive=true --tty=false" --no-build --no-load --ghci-options -ignore-dot-ghci my-project
...

当我 运行 那条线时,我得到:

Did not find executable at specified path: /home/jesuspc/.stack/compiler-tools/x86_64-linux-dke094d5208e8a802cb369cecdad3049ae/ghc-8.2.2/bin/intero

这可能与 nix 有关,因为我发现 运行ning 而不是:

stack ghci --with-ghc /home/jesuspc/.stack/compiler-tools/x86_64-linux-nix/ghc-8.2.2/bin/intero "--docker-run-args=--interactive=true --tty=false" --no-build --no-load --ghci-options -ignore-dot-ghci my-project

我得到一个不同的错误:

/home/jesuspc/.stack/compiler-tools/x86_64-linux-nix/ghc-8.2.2/bin/intero: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)

我认为可能会抛出此错误,因为我的项目使用了外部库但无法找到它们,但这只是一个猜测。

intero-mode 是否知道堆栈-docker 集成?它似乎试图在我的本地机器上使用 intero 可执行文件,而不是使用 docker 上下文,其中存在所有必需的库。我该如何解决?

我昨天也刚遇到这个问题。看起来问题出在函数 intero-copy-compiler-tool-auto-install 中 它没有考虑您的 stack.yaml 文件,因此不会将 intero 构建到 docker 容器中。我发现的一个超级 hacky 解决方法是 运行

stack --docker build --copy-compiler-tool intero

在您的项目中。