Cabal更新“压缩流过早结束”错误

时间:2015-02-12 19:20:33

标签: haskell zlib cabal cabal-install

我的cabal实例,每当我尝试运行cabal updatecabal install foo时都会出错:

Downloading the latest package list from hackage.haskell.org cabal: Codec.Compression.Zlib: premature end of compressed stream

我正在运行cabal版本1.22.0.0和GHC版本7.8.4。我在Arch Linux上,并使用官方存储库中的标准haskell软件包。

运行cabal update -v3(删除〜/ .cabal /后)的完整错误是:

Config file path source is default config file.
Config file /home/username/.cabal/config not found.
Writing default configuration to /home/username/.cabal/config
Downloading the latest package list from hackage.haskell.org
Sending:
GET /packages/archive/00-index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.22.0.0 (linux; x86_64)

Creating new connection to hackage.haskell.org
Received:
HTTP/1.0 301 Moved Permanently
Server: nginx/1.6.2
Content-Type: text/plain; charset=UTF-8
Location: /packages/index.tar.gz
Accept-Ranges: bytes
Date: Thu, 12 Feb 2015 19:15:22 GMT
Via: 1.1 varnish
X-Served-By: cache-jfk1033-JFK
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1423768522.169450,VS0,VE77
X-Cache: MISS from none
X-Cache-Lookup: MISS from none:3128
Connection: close

301 - redirect
Redirecting to http://hackage.haskell.org/packages/index.tar.gz ...
Sending:
GET /packages/index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.22.0.0 (linux; x86_64)

Creating new connection to hackage.haskell.org
Received:
HTTP/1.0 200 OK
Server: nginx/1.6.2
Content-Type: application/x-gzip
Cache-Control: public, no-transform, max-age=300
Content-MD5: f1640f2ce5cbf266c91d4062ea470689
ETag: "f1640f2ce5cbf266c91d4062ea470689"
Last-Modified: Thu, 12 Feb 2015 19:07:27 GMT
Content-Length: 8825306
Accept-Ranges: bytes
Date: Thu, 12 Feb 2015 19:15:22 GMT
Via: 1.1 varnish
Age: 84
X-Served-By: cache-jfk1023-JFK
X-Cache: HIT
X-Cache-Hits: 1
X-Timer: S1423768522.419600,VS0,VE49
X-Cache: MISS from none
X-Cache-Lookup: MISS from none:3128
Connection: close

Downloaded to /home/username/.cabal/packages/hackage.haskell.org/00-index.tar.gz
cabal: Codec.Compression.Zlib: premature end of compressed stream

网上有一些对此的引用,但其中很多都很老,我仍然遇到这个问题。我在大学的网络背后,我觉得这可能是问题的一部分,但我想深究这一点,并了解发生了什么。提前谢谢!

1 个答案:

答案 0 :(得分:5)

在找到实际解决方案之前,我想发布一个解决方法,以帮助遇到此问题的其他人:

  • 转到下载索引的位置(在我的计算机上,它位于~/.cabal/packages/hackage.haskell.org/目录中)

  • 然后手动下载该文件,例如使用wget:wget http://hackage.haskell.org/packages/archive/00-index.tar.gz(文件名可能不同,因此请务必检查您的cabal在尝试时输出的内容更新)

  • 最后,使用gunzip 00-index.tar.gz

  • 解压缩文件
  • 现在您可以cabal install打包。

这适用于我的机器,这样索引可以每隔一段时间手动更新一次。但要小心,因为在手动下载后运行“cabal update”可能会搞砸了,虽然我不确定是否一定会这样。