【问题标题】:Could not find module in nix-shell在 nix-shell 中找不到模块
【发布时间】:2017-10-18 05:56:49
【问题描述】:

missing module 的原因可能是什么?

$ nix-shell -p haskellPackages.ghc -p haskellPackages.random

给出下面的shell

[nix-shell:~]$ ghci 
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /data/works/dotfiles/ghci
Prelude> import System.Random

<no location info>: error:
    Could not find module ‘System.Random’
    It is not a module in the current program, or in any known package.

以及nix 安装和使用 Haskell 包的方式是什么?

我以为nixos.haskellPackages.&lt;package&gt; 会自动注册 ghc,但似乎并非如此。

在shell中重新安装random不要修复它。

[nix-shell:~]$ nix-env -iA nixos.haskellPackages.random
installing ‘random-1.1’

[nix-shell:~]$ ghc-pkg list | grep -i random

【问题讨论】:

标签: haskell nix nixos


【解决方案1】:

我不知道这不起作用的原因。但是你可以试试这个命令:

nix-shell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [random])"

为我工作。现在ghci 看到System.Random 包。

更新:

这篇文章对初学者的nix + haskell冒险真的很有帮助:

http://alpmestan.com/posts/2017-09-06-quick-haskell-hacking-with-nix.html

【讨论】:

  • 此方法仅适用于ghc,不适用于ghc-mod$ nix-shell -p "haskellPackages.ghcWithPackages (self: with self; [random ghc-mod])";我对 nixos haskell 系统很困惑。
  • 我写了另一个问题的答案,我解释了为什么它不起作用:stackoverflow.com/a/45023011/450128(问题本身并不是严格重复的)
猜你喜欢
  • 2021-09-29
  • 2020-05-05
  • 2016-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-15
  • 1970-01-01
相关资源
最近更新 更多