【发布时间】:2020-08-06 02:57:10
【问题描述】:
我正在尝试使用 Parsec 包。
当我运行 ghc Main.hs 时,我收到错误消息:
Could not load module ‘Text.Parsec’
It is a member of the hidden package ‘parsec-3.1.14.0’.
You can run ‘:set -package parsec’ to expose it.
但是,包应该已经暴露了:ghc-pkg list给
usr/lib/ghc/package.conf.d
Agda-2.6.0.1
Cabal-2.4.0.1
...
parsec-3.1.13.0
...
我应该怎么做才能让 ghc 自动加载它?
完整的错误信息提到了包的两个版本:
ExpScanner.hs:13:1: error:
Could not load module ‘Text.Parsec’
It is a member of the hidden package ‘parsec-3.1.14.0’.
You can run ‘:set -package parsec’ to expose it.
(Note: this unloads all the modules in the current scope.)
It is a member of the hidden package ‘parsec-3.1.13.0’.
You can run ‘:set -package parsec’ to expose it.
(Note: this unloads all the modules in the current scope.)
Use -v to see a list of the files searched for.
ExpScanner.hs 是 Main 调用的模块。
ghc-pkg list 的完整输出是
/usr/lib/ghc/package.conf.d
Agda-2.6.0.1
Cabal-2.4.0.1
EdisonAPI-1.3.1
EdisonCore-1.3.2.1
GLURaw-2.0.0.4
GLUT-2.7.0.15
HTTP-4000.3.14
HUnit-1.6.0.0
ObjectName-1.1.0.1
OpenGL-3.0.3.0
OpenGLRaw-3.3.3.0
QuickCheck-2.12.6.1
STMonadTrans-0.4.3
StateVar-1.1.1.1
aeson-1.4.2.0
array-0.5.3.0
async-2.2.2
attoparsec-0.13.2.2
base-4.12.0.0
base-compat-0.10.5
binary-0.8.6.0
blaze-builder-0.4.1.0
blaze-html-0.9.1.1
blaze-markup-0.8.2.2
boxes-0.1.5
bytestring-0.10.8.2
call-stack-0.1.0
case-insensitive-1.2.0.11
containers-0.6.0.1
data-hash-0.2.0.1
deepseq-1.4.4.0
directory-1.3.3.0
dlist-0.8.0.6
edit-distance-0.2.2.1
equivalence-0.3.4
erf-2.0.0.0
exceptions-0.10.2
fgl-5.7.0.1
filepath-1.4.2.1
fixed-0.2.1.1
geniplate-mirror-0.7.6
ghc-8.6.5
ghc-boot-8.6.5
ghc-boot-th-8.6.5
ghc-compact-0.1.0.0
ghc-heap-8.6.5
ghc-prim-0.5.3
ghci-8.6.5
gitrev-1.3.1
half-0.3
hashable-1.2.7.0
hashtables-1.2.3.3
haskeline-0.7.4.3
haskell-src-1.0.3.0
hpc-0.6.0.3
html-1.0.1.2
ieee754-0.8.0
integer-gmp-1.0.2.0
integer-logarithms-1.0.3
libiserv-8.6.3
mtl-2.2.2
murmur-hash-0.1.0.9
network-2.8.0.1
network-uri-2.6.1.0
parallel-3.2.2.0
parsec-3.1.13.0
pretty-1.1.3.6
primitive-0.6.4.0
process-1.6.5.0
random-1.1
regex-base-0.93.2
regex-compat-0.95.1
regex-posix-0.95.2
regex-tdfa-1.2.3.2
rts-1.0
scientific-0.3.6.2
split-0.2.3.3
stm-2.5.0.0
strict-0.3.2
syb-0.7.1
tagged-0.8.6
template-haskell-2.14.0.0
terminfo-0.4.1.2
text-1.2.3.1
tf-random-0.5
th-abstraction-0.2.11.0
time-1.8.0.2
time-locale-compat-0.1.1.5
transformers-0.5.6.2
transformers-compat-0.6.5
unix-2.7.2.2
unordered-containers-0.2.10.0
uri-encode-1.5.0.5
utf8-string-1.0.1.1
uuid-types-1.0.3
vector-0.12.0.3
xhtml-3000.2.2.1
zlib-0.6.2
/home/venanzio/.ghc/x86_64-linux-8.6.5/package.conf.d
Cabal-3.2.0.0
base16-bytestring-0.1.1.6
base64-bytestring-1.0.0.3
conway-0.1.0.0
cryptohash-sha256-0.11.101.0
echo-0.1.3
ed25519-0.0.5.0
hackage-security-0.6.0.1
lukko-0.1.1.2
resolv-0.1.2.0
tar-0.5.1.1
【问题讨论】:
-
看起来他们是同一个包的不同版本
-
parsec-3.1.14.0与parsec-3.1.13.0不是同一个包。其他事情正在发生。你是如何安装包的?你在什么环境下运行 ghc?ghc-pkg list的完整输出是什么? -
我将
ghc-pkg list的完整输出添加到我的帖子中。我在 ubuntu 中运行 ghc,并使用cabal install parserc安装了 parsec。 -
我刚刚发现,如果我以超级用户
sudo ghc Main.hs的身份进行操作,它就可以工作。我不明白为什么以本地用户身份运行它时会出错。