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.

ただし、コマンドにpwdorを追加します。ls

(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")`

shell-file-nameこれは Windows 10 上であり、emacs (つまり、上記の elisp 式) でデフォルト シェル (cygwin、git bash、cmd など) として設定したものに関係なく発生します。

一方、emacs の外部で各シェル/ターミナルをロードするか、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

詳細と私が試したことすべてについては、以前の(あまり具体的ではない)質問を参照してください。

cabal プロジェクトを使用した emacs haskell-mode。「` --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 に答える