O.Phillips
O.Phillips

Reputation: 451

ghc-pkg: cannot find package ghc-7.10.2.20150906

I need to expose a package ghc-7.10.2.20150906. When I use "ghc-pkg list", I see this:enter image description here

But when I'm trying to expose ghc-7.10.2.20150906 by sudo ghc-pkg expose ghc-7.10.2.20150906, I get a message:

ghc-pkg: cannot find package ghc-7.10.2.20150906

What's the problem? Or is there another way to expose it?

Cabal file:

-- This is the configuration file for the 'cabal' command line tool.

-- The available configuration options are listed below.
-- Some of them have default values listed.

-- Lines (like this one) beginning with '--' are comments.
-- Be careful with spaces and indentation because they are
-- used to indicate layout for nested sections.


remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
remote-repo-cache: /home/valoisa/.cabal/packages
-- local-repo:
-- logs-dir:
world-file: /home/valoisa/.cabal/world
-- verbose: 1
-- compiler: ghc
-- with-compiler:
-- with-hc-pkg:
-- scratchdir:
-- program-prefix: 
-- program-suffix: 
-- library-vanilla: True
-- library-profiling: False
-- shared:
-- executable-dynamic: False
-- executable-profiling: False
-- optimization: True
-- library-for-ghci: False
-- split-objs: False
-- executable-stripping: True
-- user-install: True
-- package-db:
-- flags:
-- extra-include-dirs:
-- extra-lib-dirs:
extra-prog-path: /home/valoisa/.cabal/bin
-- tests: False
-- library-coverage: False
-- benchmarks: False
-- cabal-lib-version:
-- constraint:
-- preference:
-- solver: choose
-- documentation: False
-- doc-index-file: $datadir/doc/index.html
-- max-backjumps: 2000
-- reorder-goals: False
-- shadow-installed-packages: False
-- strong-flags: False
-- reinstall: False
-- avoid-reinstalls: False
-- force-reinstalls: False
-- upgrade-dependencies: False
-- root-cmd:
-- symlink-bindir:
build-summary: /home/valoisa/.cabal/logs/build.log
-- build-log:
remote-build-reporting: anonymous
-- one-shot: False
jobs: $ncpus
-- username:
-- password:

install-dirs user
  -- prefix: /home/valoisa/.cabal
  -- bindir: $prefix/bin
  -- libdir: $prefix/lib
  -- libsubdir: $arch-$os-$compiler/$pkgid
  -- libexecdir: $prefix/libexec
  -- datadir: $prefix/share
  -- datasubdir: $arch-$os-$compiler/$pkgid
  -- docdir: $datadir/doc/$arch-$os-$compiler/$pkgid
  -- htmldir: $docdir/html
  -- haddockdir: $htmldir
  -- sysconfdir: $prefix/etc

install-dirs global
  -- prefix: /usr/local
  -- bindir: $prefix/bin
  -- libdir: $prefix/lib
  -- libsubdir: $arch-$os-$compiler/$pkgid
  -- libexecdir: $prefix/libexec
  -- datadir: $prefix/share
  -- datasubdir: $arch-$os-$compiler/$pkgid
  -- docdir: $datadir/doc/$arch-$os-$compiler/$pkgid
  -- htmldir: $docdir/html
  -- haddockdir: $htmldir
  -- sysconfdir: $prefix/etc

program-locations 
  -- alex-location:
  -- ar-location:
  -- c2hs-location:
  -- cpphs-location:
  -- ffihugs-location:
  -- gcc-location:
  -- ghc-location:
  -- ghc-pkg-location:
  -- greencard-location:
  -- haddock-location:
  -- happy-location:
  -- hmake-location:
  -- hpc-location:
  -- hsc2hs-location:
  -- hscolour-location:
  -- hugs-location:
  -- jhc-location:
  -- ld-location:
  -- lhc-location:
  -- lhc-pkg-location:
  -- nhc98-location:
  -- pkg-config-location:
  -- ranlib-location:
  -- strip-location:
  -- tar-location:
  -- uhc-location:

program-default-options 
  -- alex-options:
  -- ar-options:
  -- c2hs-options:
  -- cpphs-options:
  -- ffihugs-options:
  -- gcc-options:
  -- ghc-options:
  -- ghc-pkg-options:
  -- greencard-options:
  -- haddock-options:
  -- happy-options:
  -- hmake-options:
  -- hpc-options:
  -- hsc2hs-options:
  -- hscolour-options:
  -- hugs-options:
  -- jhc-options:
  -- ld-options:
  -- lhc-options:
  -- lhc-pkg-options:
  -- nhc98-options:
  -- pkg-config-options:
  -- ranlib-options:
  -- strip-options:
  -- tar-options:
  -- uhc-options:

Upvotes: 1

Views: 954

Answers (1)

ase
ase

Reputation: 13491

Usually when you're writing a larger Haskell project you would specify the packages that you want to use in a project specific Cabal file, here is a quite minimal example that uses the base package and the ghc package, example.cabal:

name:                example
version:             0.1.0.0
build-type:          Simple
cabal-version:       >=1.10

library
  exposed-modules:     AModule
  build-depends:       base >= 4.7 && < 5
                       , ghc
  default-language:    Haskell2010

To use the GHC 7.10.3 snapshot with this project you run cabal configure --with-compiler=PATH/TO/ghc-7.10.3, then you can access your project with the dependent packages in a GHCi session using cabal repl.


If you really want to expose the ghc package your problem seems to be that the sudo ghc-pkg invocation is not the ghc-pkg from the 7.10.3 snapshot, as evidenced by the line

flag db stack: ["/home/valoisa/.ghc/x86_64-linux-7.10.2/package.conf.d","/usr/local/lib/ghc-7.10.2/package.conf.d"]

in the output of sudo ghc-pkg -v2 expose ghc you posted.

I can see two possible solutions

  1. Don't use sudo as it seems the correct version of ghc-pkg is used (I can't think of any reason to use sudo here).
  2. Use the correct ghc-pkg by specifying the whole path to the program.

Upvotes: 2

Related Questions