微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Cabal 如何确定它所在的目录并寻找目标?

如何解决Cabal 如何确定它所在的目录并寻找目标?

我在打开 emacs haskell 模式时遇到一个奇怪的错误。当 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 等)都会发生(即上面 elisp 表达式中的 shell-file-name)。

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

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

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


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

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

emacs haskell-mode with cabal project. "Unrecognised target syntax for ` --ghc-option=ferror-spans`."

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。