Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AndreasPK opened this issue Sep 8, 2018 · 21 comments
Open

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

AndreasPK opened this issue Sep 8, 2018 · 21 comments
Labels
cabal-install: cmd/update can-workaround There is a (maybe partial) workaround for the issue or missing feature type: bug

Comments

@AndreasPK
Copy link
Collaborator

AndreasPK commented Sep 8, 2018

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.

@hvr
Copy link
Member

hvr commented Sep 9, 2018

@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?

@AndreasPK
Copy link
Collaborator Author

Will do if I remember next time!

@abarrasso
Copy link

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'?

@AndreasPK
Copy link
Collaborator Author

I had forgotten about this.

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

@abarrasso
Copy link

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
Copy link

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

@AndreasPK
Copy link
Collaborator Author

On Linux: rm ~/.cabal -rf

@fidel-ml
Copy link

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?

@jneira
Copy link
Member

jneira commented Jun 19, 2019

@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.

@fidel-ml
Copy link

fidel-ml commented Jun 19, 2019

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
Copy link

fidel-ml commented Jun 19, 2019

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... :(

@23Skidoo
Copy link
Member

Selected http transport implementation: curl

Do you have curl in PATH?

@23Skidoo
Copy link
Member

You can also try deleting 01-index* files.

@fidel-ml
Copy link

fidel-ml commented Jun 19, 2019

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"

@jneira
Copy link
Member

jneira commented Jun 19, 2019

@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

@fidel-ml
Copy link

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

@mcandre
Copy link

mcandre commented Feb 21, 2020

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.

@nh2
Copy link
Member

nh2 commented Mar 21, 2020

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.

@GeorgeCo
Copy link

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?

@phadej
Copy link
Collaborator

phadej commented Jan 29, 2021

Delete just ~/.cabal/packages.

@jvanbruegge
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-install: cmd/update can-workaround There is a (maybe partial) workaround for the issue or missing feature type: bug
Projects
None yet
Development

No branches or pull requests