【问题标题】:How to reset Haskell package cache如何重置 Haskell 包缓存
【发布时间】:2014-02-15 01:55:29
【问题描述】:

决定学习 Haskell,通过 Homebrew 在 OS X 上安装了 ghc(当时没有下载网络二进制文件)。

一切都很好,跟着Learn You a Haskell,但后来决定安装一些包,看看事情是如何运行的。

cabal install clckwrks-cli 一直运行良好,直到...

在安装/构建几个项目的过程中,公共互联网崩溃了。

现在,这些程序都不会重新安装,对于 clckwrks-cli,我收到以下错误:

$ cabal install clckwrks-cli --reinstall --force-reinstalls
Resolving dependencies...
Failed to install cipher-aes-0.2.6
Failed to install cipher-rc4-0.1.4
Failed to install cookie-0.4.0.1
Failed to install crypto-numbers-0.2.3
Configuring happstack-hsp-7.2.4...
Building happstack-hsp-7.2.4...
Preprocessing library happstack-hsp-7.2.4...
ghc: could not execute: hsx2hs
Failed to install happstack-hsp-7.2.4
Failed to install lifted-base-0.2.2.0
Failed to install publicsuffixlist-0.1
Failed to install pwstore-purehaskell-2.1.1
Configuring reform-hsp-0.2.4...
Building reform-hsp-0.2.4...
Preprocessing library reform-hsp-0.2.4...
ghc: could not execute: hsx2hs
Failed to install reform-hsp-0.2.4
Failed to install web-plugins-0.2.5
Failed to install wl-pprint-text-1.1.0.2
Failed to install xml-types-0.3.4
cabal: Error: some packages failed to install:
attoparsec-conduit-1.0.1.2 depends on lifted-base-0.2.2.0 which failed to
install.
authenticate-1.3.2.6 depends on xml-types-0.3.4 which failed to install.
blaze-builder-conduit-1.0.0 depends on lifted-base-0.2.2.0 which failed to
install.
cipher-aes-0.2.6 failed while unpacking the package. The exception was:
user error (data is not in tar format)
cipher-rc4-0.1.4 failed while unpacking the package. The exception was:
user error (data is not in tar format)
clckwrks-0.21.1 depends on xml-types-0.3.4 which failed to install.
clckwrks-cli-0.2.10 depends on xml-types-0.3.4 which failed to install.
conduit-1.0.14 depends on lifted-base-0.2.2.0 which failed to install.
cookie-0.4.0.1 failed while unpacking the package. The exception was:
user error (data is not in tar format)
cprng-aes-0.5.2 depends on cipher-aes-0.2.6 which failed to install.
crypto-numbers-0.2.3 failed while unpacking the package. The exception was:
user error (data is not in tar format)
crypto-pubkey-0.2.4 depends on crypto-numbers-0.2.3 which failed to install.
fb-0.14.11 depends on publicsuffixlist-0.1 which failed to install.
happstack-authenticate-0.10.10 depends on xml-types-0.3.4 which failed to
install.
happstack-hsp-7.2.4 failed during the building phase. The exception was:
ExitFailure 1
hsx-jmacro-7.3.4 depends on wl-pprint-text-1.1.0.2 which failed to install.
http-conduit-1.9.6 depends on publicsuffixlist-0.1 which failed to install.
jmacro-0.6.8 depends on wl-pprint-text-1.1.0.2 which failed to install.
lifted-base-0.2.2.0 failed while unpacking the package. The exception was:
user error (data is not in tar format)
monad-logger-0.3.4.0 depends on lifted-base-0.2.2.0 which failed to install.
publicsuffixlist-0.1 failed while unpacking the package. The exception was:
user error (data is not in tar format)
pwstore-purehaskell-2.1.1 failed while unpacking the package. The exception
was:
user error (data is not in tar format)
reform-hsp-0.2.4 failed during the building phase. The exception was:
ExitFailure 1
resourcet-0.4.10 depends on lifted-base-0.2.2.0 which failed to install.
tls-1.1.5 depends on crypto-numbers-0.2.3 which failed to install.
tls-extra-0.6.6 depends on crypto-numbers-0.2.3 which failed to install.
web-plugins-0.2.5 failed while unpacking the package. The exception was:
user error (data is not in tar format)
wl-pprint-text-1.1.0.2 failed while unpacking the package. The exception was:
user error (data is not in tar format)
xml-conduit-1.1.0.9 depends on xml-types-0.3.4 which failed to install.
xml-types-0.3.4 failed while unpacking the package. The exception was:
user error (data is not in tar format)
zlib-conduit-1.0.0 depends on lifted-base-0.2.2.0 which failed to install.

其他一些在安装过程中遇到同样网络中断的项目也存在同样的问题。

到目前为止喜欢这种语言,而不是包管理:(

【问题讨论】:

  • 试试rm -rf ~/.cabal/packages/* - 它可能有效
  • 另一个有用的技巧是rm -rf ~/.ghc 删除所有已安装的包。如果您不知道还能做什么,这会很激烈但很有帮助。
  • 您可以用ghc-pkg check 询问GHC 它认为什么问题。
  • 在 OS X 上,要重置用户安装的软件包,您应该删除 ~/.ghc~/Library/Haskell,这是 cabal 保留用户软件包的地方。然后遵循@Danny Navarro 关于沙盒的建议。
  • Stack 用户:rm -rf ~/.stack/ 删除整个目录很重要;如果您只删除快照和包,您将收到 can't load .so/.DLL for... 错误。

标签: haskell cabal package-management


【解决方案1】:

Cabal sandboxes 经常被推荐用于开发,但可以很好地快速尝试一些包。如果出现任何问题,它们很容易被丢弃,并且不会影响您已经安装的任何其他软件包。以下是我尝试clckwrks-cli 的方法(顺便说一句,如果您想尝试任何软件包,您可能会选择另一个依赖较少的软件包)。

$ cd /path/to/sandboxes
$ cabal get clckwrks-cli
$ cd clckwrks-cli-<version>
$ cabal sandbox init
$ cabal install --only-dependencies -j<N> # N is the number of CPU cores

此时,您可以键入cabal run 来运行软件包安装的可执行文件(它可能位于./dist/build/bin/),cabal test 用于运行测试,或cabal repl 以运行@ 987654328@ 会话与可用的沙盒包。

如果出现任何问题,您可以通过键入 cabal sandbox deletecabal clean 来恢复沙盒。完成后,您可以安全地移除沙箱,而不会影响其他包。

【讨论】:

    【解决方案2】:

    这是过去对我有用的方法 对于一个包 $f,做

    ghc-pkg.exe unregister --global --force $f
    ghc-pkg.exe recache
    

    根据其文档,ghc-pkg.exe unregister“取消注册包”并重新缓存“重新生成包数据库缓存”。如果有问题的软件包安装在系统目录中,则需要使用--global

    如果数据库严重损坏,我会删除用户或系统 cabal 目录并重新安装我拥有的软件包。我通常通过cabal install 我使用的一个或几个应用程序库来执行此操作,然后让cabal 重新安装依赖项。注意:cabal 目录取决于操作系统和 GHC 的版本。


    ghc-pkg 注销 --force clckwrks-cli

    【讨论】:

    • ghc-pkg: cannot find package clckwrks-cli
    • 您能详细说明这是什么意思吗?
    • 感谢ghc-pkg.exe recache。该命令直接回答了标题中的问题。这对我有帮助。
    【解决方案3】:

    我在使用 unordered-containers-0.2.5.1 并删除文件时遇到问题:

    ~/.cabal/packages/hackage.haskell.org/unordered-containers/0.2.5.1/unordered-containers-0.2.5.1.tar.gz
    

    为我解决了这个问题。 (即错误cabal: data is not in tar format

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-31
      • 2012-05-07
      • 1970-01-01
      • 1970-01-01
      • 2020-10-02
      • 1970-01-01
      • 1970-01-01
      • 2020-10-11
      相关资源
      最近更新 更多