在Nix中,如何告诉“ Haskell语言服务器”以在当前项目中启用标志?

发布于 2025-02-13 04:23:22 字数 1367 浏览 0 评论 0原文

我的Nix Project的Cabal文件定义了一个标志,但默认情况下将其禁用:

flag with-examples
  description: Include examples and their dependencies
  default:     False

但是当我在Nix-shell中运行Haskell-Language-Server时,它说:

Hidden:   no
Range:    1:1-2:1
Source:   cradle
Severity: DsError
Message: 
  Error when calling cabal exec -v0 -- ghc --print-libdir

  cabal: Could not resolve dependencies:
  [__0] trying: ema-0.7.2.0 (user goal)
  [__1] rejecting: ema:-with-examples (constraint from config file, command line
  flag, or user target requires opposite flag selection)
  [__1] trying: ema:+with-examples
  [__2] unknown package: fsnotify (dependency of ema +with-examples)
  [__2] fail (backjumping, conflict set: ema, fsnotify, ema:with-examples)
  After searching the rest of the dependency tree exhaustively, these were the
  goals I've had most trouble fulfilling: ema, ema:with-examples, fsnotify

在使标志true true之后,错误消失了默认,但这显然是不希望的行为。有没有办法修复HLS的这种行为?

我尝试使用cabal.project flags添加cabal。


复制此错误:(

git clone https://github.com/EmaApps/ema.git -b multisite
cd multisite && nix develop
nvim ema.cabal ## Make both the flags default: False
haskell-language-server

编辑以澄清这是Nix独有的)

My Nix project's cabal file defines a flag but leaves it disabled by default:

flag with-examples
  description: Include examples and their dependencies
  default:     False

But when I run haskell-language-server in the nix-shell, it says:

Hidden:   no
Range:    1:1-2:1
Source:   cradle
Severity: DsError
Message: 
  Error when calling cabal exec -v0 -- ghc --print-libdir

  cabal: Could not resolve dependencies:
  [__0] trying: ema-0.7.2.0 (user goal)
  [__1] rejecting: ema:-with-examples (constraint from config file, command line
  flag, or user target requires opposite flag selection)
  [__1] trying: ema:+with-examples
  [__2] unknown package: fsnotify (dependency of ema +with-examples)
  [__2] fail (backjumping, conflict set: ema, fsnotify, ema:with-examples)
  After searching the rest of the dependency tree exhaustively, these were the
  goals I've had most trouble fulfilling: ema, ema:with-examples, fsnotify

The error goes away after making the flag True by default, but this is a clearly undesired behavior. Is there a way to fix this behavior of HLS?

I tried adding a cabal.project file with flags: +with-examples but that makes no difference.


To reproduce this error:

git clone https://github.com/EmaApps/ema.git -b multisite
cd multisite && nix develop
nvim ema.cabal ## Make both the flags default: False
haskell-language-server

(edited to clarify this is unique to Nix)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文