ghc-pkg: 找不到软件包 ghc-7.10.2.20150906

ghc-pkg: cannot find package ghc-7.10.2.20150906

我需要公开一个包 ghc-7.10.2.20150906。 当我使用 "ghc-pkg list" 时,我看到这个:

但是当我试图通过 sudo ghc-pkg expose ghc-7.10.2.20150906 公开 ghc-7.10.2.20150906 时,我收到一条消息:

ghc-pkg: cannot find package ghc-7.10.2.20150906

有什么问题吗?还是有其他方法暴露它?

Cabal 文件:

-- 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:

通常当你写一个更大的 Haskell 项目时,你会指定你想在项目特定的 Cabal 文件中使用的包,这里是一个使用 base包和 ghc 包,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

要将 GHC 7.10.3 快照与此项目一起使用,您 运行 cabal configure --with-compiler=PATH/TO/ghc-7.10.3,然后您可以使用 cabal repl 在 GHCi 会话中使用依赖包访问您的项目。


如果您真的想公开 ghc 包,您的问题似乎是 sudo ghc-pkg 调用不是来自 7.10.3 快照的 ghc-pkg,如行

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"]

在您发布的 sudo ghc-pkg -v2 expose ghcoutput 中。

我可以看到两种可能的解决方案

  1. 不要使用 sudo,因为似乎使用了正确版本的 ghc-pkg(我想不出有什么理由在这里使用 sudo)。
  2. 通过指定程序的完整路径来使用正确的ghc-pkg