我的 cabal 实例,每当我尝试运行 cabal update
或 cabal install foo
时都会出现错误:
从 hackage.haskell.org 下载最新的软件包列表
cabal:Codec.Compression.Zlib:压缩流过早结束
我正在运行 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
网上有一些对此的引用,但其中很多都非常旧,而且我仍然遇到这个问题。我是大学网络的幕后黑手,我觉得这可能是问题的一部分,但我想深入了解并了解正在发生的事情。提前致谢!
最佳答案
在找到实际的解决方案之前,我想发布一个解决方法,以帮助其他遇到此问题的人:
转到下载索引的位置(在我的计算机上,它位于目录
~/.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”可能会搞砸,尽管我不确定是否一定会这样。
关于haskell - Cabal更新 "premature end of compressed stream"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28485981/