2

我在 emacs haskell-mode on 中遇到了一个奇怪的错误。当 emacs 通过以下方式调用 cabal 进程时:

(call-process shell-file-name  nil output nil shell-command-switch "cabal build")

构建失败,就好像cabal 在错误的目录中一样:

cabal.exe: No targets given and there is no package in the current directory. 
Use the target 'all' for all packages in the project or specify packages or 
components by name or location. See 'cabal build --help' for more details on 
target options.

但附加pwdls命令即:

(call-process shell-file-name  nil output nil shell-command-switch "pwd ; cabal build")

显示它在正确的目录中:

f/path/to/my-project 
cabal.exe: No targets given and there is no package in the current directory. 
Use the target 'all' for all packages in the project or specify packages or 
components by name or location. See 'cabal build --help' for more details on 
target options.

将命令更改为:

(call-process shell-file-name  nil output nil shell-command-switch "cabal build all")

工作正常,奇怪的是,也是如此:

(call-process shell-file-name  nil output nil shell-command-switch "cd . ; cabal build")`

这是在 Windows 10 上发生的,无论我在 emacs 中将什么设置为默认 shell(cygwin、git bash、cmd 等)(即shell-file-name在上面的 elisp 表达式中)。

同时,如果我在 emacs 之外加载每个 shell/终端,或者如果我降级到 cabal 2.4,它构建得很好,问题就消失了。

试图在 Ubuntu 20.04(带有 cabal 2.4 和 3.2)上复制该问题但失败了,所以我的猜测是这是特定于 Windows 的,并且与 2.4 相比,cabal 3.2 的一些新行为。

谁能解释这种奇怪的行为?


设置:Windows 10、GHC 8.10.2、Cabal 3.2.0.0、emacs 27.1、haskell-mode 20201120.755

有关更多详细信息和我尝试过的所有内容,请参阅以前的(不太具体的)问题:

emacs haskell-mode 与 cabal 项目。“`--ghc-option=ferror-spans` 的目标语法无法识别。”

https://emacs.stackexchange.com/questions/63078/bizarre-behaviour-using-call-process-cabal-fails-as-if-it-is-in-wrong-directo

4

1 回答 1

2

由于答案被一个过分热心的 mod 隐藏了,我将重新发布:这个问题是由于 Windows 上 Cabal 中的路径处理中的错误造成的。

正在进行的 PR 可以解决此问题:https ://github.com/haskell/cabal/pull/7310

于 2021-08-12T04:44:48.017 回答