Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ghc error: hidden package, but it's actually exposed

Tags:

haskell

ghc

I'm trying to use the package Parsec. When I run ghc Main.hs I get the error message:

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.

However, the package is supposed to be exposed already: ghc-pkg list gives

usr/lib/ghc/package.conf.d
    Agda-2.6.0.1
    Cabal-2.4.0.1
    ...
    parsec-3.1.13.0
    ...

What should I do get ghc load it automatically?

The full error message mentioned both versions of the package:

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 is a moduled called by Main.

The full output of ghc-pkg list is

/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
like image 545
Eubulide Avatar asked Dec 14 '25 14:12

Eubulide


1 Answers

This looks like an issue with global vs local installs. Oh, and there it is in your ghc-pkg list output. You've got a multiuser ghc install and a single-user list of packages you've installed. Things work when you run ghc as a superuser because they won't see your local (per-user) installs.

This is going to cause problems unless you use a tool to manage your environment for you. Both cabal and stack can handle this fine. I prefer cabal because it doesn't need coaxing to work with your preinstalled GHC, but this is a matter that has caused religious wars in the past. I won't argue against stack if you have a good resource for using it instead.

like image 172
Carl Avatar answered Dec 16 '25 15:12

Carl