4

My cabal instance, whenever I try to run cabal update or cabal install foo keeps giving the error:

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

I'm running cabal version 1.22.0.0, and GHC version 7.8.4. I'm on Arch Linux, and using the standard haskell packages from the official repository.

The full error when running cabal update -v3 (after deleting ~/.cabal/) is:

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

There are a few references to this across the web, but a lot of them are very old, and I am still having this problem. I'm behind my university's network which I feel might be part of the issue, but I want to get to the bottom of this and understand what's happening. Thanks in advance!

Nathan
  • 73,987
  • 14
  • 40
  • 69
  • 4
    This is an open issue with cabal: https://github.com/haskell/cabal/issues/2001 I myself have faced this when using cabal behind a proxy. Sometimes downgrading to a lower version (1.18, I think) has helped me in solving the problem. – Sibi Feb 12 '15 at 20:11

1 Answers1

5

Until an actual solution is found, I want to post a workaround, to help other people who have this problem:

  • Go to where the index is being downloaded (on my machine, it is in the directory ~/.cabal/packages/hackage.haskell.org/)

  • Then manually download the file, for example by using wget: wget http://hackage.haskell.org/packages/archive/00-index.tar.gz (the file name might be different, so make sure to check what your cabal outputs when it tries to update)

  • Lastly, unzip the file with gunzip 00-index.tar.gz

  • Now you can cabal install packages.

This works on my machine, and this way the index can be manually updated every once and awhile. Be careful though, as running "cabal update" could possibly mess this up after manually downloading, although I'm not sure if it necessarily would.

Nathan
  • 73,987
  • 14
  • 40
  • 69