cabal icon indicating copy to clipboard operation
cabal copied to clipboard

Error: Could not read index. Did you call 'checkForUpdates'?

Open AndreasPK opened this issue 5 years ago • 21 comments

This seems like something aimed at users of cabal-the-library and gives zero indication on how to fix this.

Andi@Horzube MINGW64 ~/hc_bench/libs/binary/c_allCalls
$ cabal --version
cabal-install version 2.5.0.0
compiled using version 2.5.0.0 of the Cabal library

Andi@Horzube MINGW64 ~/hc_bench/libs/binary/c_allCalls
$ cabal new-update
Downloading the latest package lists from:
- hackage.haskell.org
- head.hackage
cabal.exe: Could not read index. Did you call 'checkForUpdates'?

Andi@Horzube MINGW64 ~/hc_bench/libs/binary/c_allCalls
$ cabal new-update
Downloading the latest package lists from:
- hackage.haskell.org
- head.hackage
cabal.exe: Could not read index. Did you call 'checkForUpdates'?

It's rare enough that I don't mind it (that much). But it's not the first time I've run into this issue so

At least the error should give an indication on how to get cabal working again. Eg deleting the local cabal folder fixed the issue.


edit by @23Skidoo: Current workaround is to delete the 01-index.* files and retry cabal update.

AndreasPK avatar Sep 08 '18 22:09 AndreasPK

@AndreasPK I've got a hunch about why this is happening... next time this happens, can you try removing only the head.hackage folder inside cabal's app-setting folder?

hvr avatar Sep 09 '18 07:09 hvr

Will do if I remember next time!

AndreasPK avatar Sep 09 '18 09:09 AndreasPK

I am also having the same issue, does anyone have an idea? Whenever I run cabal new-repl I get the same response:

cabal: Could not read index. Did you 'checkForUpdates'?

abarrasso avatar Feb 10 '19 20:02 abarrasso

I had forgotten about this.

Iirc you can just delete the .cabal folder as a workaround.

AndreasPK avatar Feb 10 '19 20:02 AndreasPK

Sorry I don't believe that helped I tried "cabal update" afterwards and the same error message popped up. Unfortunately I have to use the command "cabal tests" which doesn't work either. I apologize if this is not clear.

abarrasso avatar Feb 10 '19 20:02 abarrasso

Hi, Do you know how to delete the .cabal folder in terminal ? Thanks!

abarrasso avatar Feb 11 '19 21:02 abarrasso

On Linux: rm ~/.cabal -rf

AndreasPK avatar Feb 12 '19 08:02 AndreasPK

I've just installed Haskell Platform 8.6.5 in Windows 10 (latest download from https://www.haskell.org/platform/), and when trying "cabal new-update" it answers with the same message reported here.

Downloading the latest package list from hackage.haskell.org cabal.exe: Could not read index. Did you call 'checkForUpdates'?

I have found no other question regarding this issue, and no solutions so far. Can I use cabal on Windows at all?

fidel-ml avatar Jun 19 '19 04:06 fidel-ml

@fidel-ml could you share the output of cabal -v3 v2-update to have a more detailed trace?

Sometimes it is related with the way cabal uses to access internet, by default curl, if the program is in path, you could try cabal --http-transport=plain-http v2-update in that case.

jneira avatar Jun 19 '19 06:06 jneira

The output of the command is:

File monitor 'config' changed: first run
Project settings changed, reconfiguring...
Downloading the latest package list from hackage.haskell.org
Searching for curl in path.
Found curl at C:\WINDOWS\SYSTEM32\curl.exe
Searching for powershell in path.
Found powershell at C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Searching for wget in path.
Cannot find wget on the path
Selected http transport implementation: curl
Updating index cache file
C:\Users\fidel\AppData\Roaming\cabal\packages\hackage.haskell.org\01-index.cache
...
cabal.exe: Could not read index. Did you call 'checkForUpdates'?

Thanks for the help! It seems that I do not have wget... The use of --http-transport flag reports the same error message. I will try installing wget, and report again. Or are there oter ways to make it run without wget?

fidel-ml avatar Jun 19 '19 13:06 fidel-ml

I have installed wget. But the error message is the same. The new output is:

File monitor 'config' changed: first run
Project settings changed, reconfiguring...
Downloading the latest package list from hackage.haskell.org
Searching for curl in path.
Found curl at C:\WINDOWS\SYSTEM32\curl.exe
Searching for powershell in path.
Found powershell at C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Searching for wget in path.
Found wget at C:\Program Files (x86)\GnuWin32\bin\wget.exe
Selected http transport implementation: curl
Updating index cache file
C:\Users\fidel\AppData\Roaming\cabal\packages\hackage.haskell.org\01-index.cache
...
cabal.exe: Could not read index. Did you call 'checkForUpdates'?

I then have checked C:\Users\fidel\AppData\Roaming\cabal\packages\hackage.haskell.org\, and there is a 01.index.tar and a 01-index.tar.gz, but no 01-index.cache. How can I create/restore that file? I've tried uncompressing the .tar file in the same directory, but no .cache... :(

fidel-ml avatar Jun 19 '19 13:06 fidel-ml

Selected http transport implementation: curl

Do you have curl in PATH?

23Skidoo avatar Jun 19 '19 13:06 23Skidoo

You can also try deleting 01-index* files.

23Skidoo avatar Jun 19 '19 13:06 23Skidoo

I delete all the 01-index* files, and it started downloading things... Now it reads as below, and its still working. It seems to be pretty big. Thanks a lot!!!! I will report as soon as it finish. :)

File monitor 'config' changed: first run
Project settings changed, reconfiguring...
Downloading the latest package list from hackage.haskell.org
Searching for curl in path.
Found curl at C:\WINDOWS\SYSTEM32\curl.exe
Searching for powershell in path.
Found powershell at C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Searching for wget in path.
Found wget at C:\Program Files (x86)\GnuWin32\bin\wget.exe
Selected http transport implementation: curl
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
Selected mirror http://hackage.haskell.org/
Downloading timestamp
"C:\WINDOWS\SYSTEM32\curl.exe" "http://hackage.haskell.org/timestamp.json" "--output" "C:\Users\fidel\AppData\Local\Temp\tra4F7D" "--location" "--write-out" "%{http_code}" "--user-agent" "cabal-install/2.4.1.0 (windows; x86_64)" "--silent" "--show-error" "--dump-header" "C:\Users\fidel\AppData\Local\Temp\cur4F7E.txt" "--header" "Cache-Control: no-transform"
Downloading snapshot
"C:\WINDOWS\SYSTEM32\curl.exe" "http://hackage.haskell.org/snapshot.json" "--output" "C:\Users\fidel\AppData\Local\Temp\tra530B" "--location" "--write-out" "%{http_code}" "--user-agent" "cabal-install/2.4.1.0 (windows; x86_64)" "--silent" "--show-error" "--dump-header" "C:\Users\fidel\AppData\Local\Temp\cur530C.txt" "--header" "Cache-Control: no-transform"
Cannot update index (no local copy)
Downloading index
"C:\WINDOWS\SYSTEM32\curl.exe" "http://hackage.haskell.org/01-index.tar.gz" "--output" "C:\Users\fidel\AppData\Local\Temp\tra562A" "--location" "--write-out" "%{http_code}" "--user-agent" "cabal-install/2.4.1.0 (windows; x86_64)" "--silent" "--show-error" "--dump-header" "C:\Users\fidel\AppData\Local\Temp\cur562B.txt" "--header" "Cache-Control: no-transform"

fidel-ml avatar Jun 19 '19 14:06 fidel-ml

@fidel-ml great! no need for wget, cabal looks for all possible programs but it is happy to use curl if it is in path

jneira avatar Jun 19 '19 14:06 jneira

It worked! My gratitude to all of you who helped.

fidel-ml avatar Jun 19 '19 14:06 fidel-ml

you can just delete the .cabal folder as a workaround.

Grr. Both update and new-update are broken in 2020 on Ubuntu. We're moving backwards.

mcandre avatar Feb 21 '20 23:02 mcandre

This just happened to me, triggered by hitting Ctrl+C.

It seems Cabal does not handle cancellation at any time correctly.

Usually that happens when programs do not use atomic writes/renames, but in this case it is that a certain file is simply not present:

In my case, strace -fye open,openat shows that it's trying to read the nonexistent file 01-index.tar.idx:

[pid  7947] openat(AT_FDCWD, "/home/niklas/.cabal/packages/hackage.haskell.org/01-index.tar.idx", O_RDONLY|O_NOCTTY|O_NONBLOCK) = -1 ENOENT (No such file or directory)

I suspect that somewhere in Cabal there is an assumption that when one of the index-related files is present, all of them are present (which cannot be guaranteed).

Probably Cabal should treat any of the files missing as having to do a re-download.

nh2 avatar Mar 21 '20 02:03 nh2

Same experience as nh2, seemed to be triggered by doing a ctrl-c. rm -fr ~/.cabal doesn't seem like a good workaround as it deletes ~/.cabal/store. How do I then get that directory tree back?

GeorgeCo avatar Jan 29 '21 00:01 GeorgeCo

Delete just ~/.cabal/packages.

phadej avatar Jan 29 '21 12:01 phadej

For future reference, this can also happen if you deleted ~/.config/cabal but not ~/.cache/cabal

jvanbruegge avatar Apr 23 '24 13:04 jvanbruegge