haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.63k stars 696 forks source link

cabal update fails #4747

Closed vagarenko closed 5 years ago

vagarenko commented 7 years ago

On my windows 7 machine cabal update command fails

>cabal --version
cabal-install version 2.0.0.0
compiled using version 2.0.0.2 of the Cabal library
> cabal update -v3
no user package environment file found at D:\projects
Downloading the latest package list from hackage.haskell.org
Searching for curl in path.
Cannot find curl on the path
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: powershell
Selected mirror http://hackage.haskell.org/
Downloading timestamp
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Downloading snapshot
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Updating index
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Exception dieVerbatim: user error (CallStack (from HasCallStack):
die', called at .\Distribution\Client\HttpUtils.hs:744:5 in
main:Distribution.Client.HttpUtils
cabal: Failed to download http://hackage.haskell.org/01-index.tar.gz : No
Status Code could be parsed from response: An exception occurred during a
WebClient request.
) when using mirror http://hackage.haskell.org/
Selected mirror http://hackage.fpcomplete.com/
Downloading timestamp
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Downloading snapshot
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Updating index
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Exception dieVerbatim: user error (CallStack (from HasCallStack):
die', called at .\Distribution\Client\HttpUtils.hs:744:5 in
main:Distribution.Client.HttpUtils
cabal: Failed to download http://hackage.fpcomplete.com/01-index.tar.gz : No
Status Code could be parsed from response: An exception occurred during a
WebClient request.
) when using mirror http://hackage.fpcomplete.com/
Selected mirror http://objects-us-west-1.dream.io/hackage-mirror/
Downloading timestamp
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Downloading snapshot
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Updating index
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
dieVerbatim: user error (CallStack (from HasCallStack):
  die', called at .\Distribution\Client\HttpUtils.hs:744:5 in main:Distribution.Client.HttpUtils
cabal: Failed to download
http://objects-us-west-1.dream.io/hackage-mirror/01-index.tar.gz : No Status
Code could be parsed from response: An exception occurred during a WebClient
request.
)

while cabal get command works fine:

> cabal get acme-zero -v3
no user package environment file found at D:\projects
Reading available packages...
index-state(hackage.haskell.org) = 2017-08-27T11:02:08Z
Downloading acme-zero-0.0.2...
writing
C:\Users\alex\AppData\Roaming\cabal\packages\hackage.haskell.org\acme-zero\0.0.2\acme-zero-0.0.2.tar.gz
Selected mirror http://hackage.haskell.org/
Downloading package acme-zero-0.0.2
Searching for curl in path.
Cannot find curl on the path
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: powershell
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Unpacking to acme-zero-0.0.2\
Updating acme-zero-0.0.2\acme-zero.cabal with the latest revision from the
index.

I tried this with firewall turned off and on with no difference

23Skidoo commented 7 years ago

It dies when trying to parse HTTP status code in the server response, in statusParseFail. I'd try debugging this by running the powershell download script manually.

http://hackage.fpcomplete.com/01-index.tar.gz

Maybe something funny is going on with server configuration. Looks like there's no way to force update to use a specific mirror, unfortunately...

hvr commented 7 years ago

@vagarenko just as a workaround, what if you use cabal --http-transport=plain-http update ?

@23Skidoo how would specifiying the mirror to use help here? the same error occurs with all 3 mirrors it cycles through automatically

23Skidoo commented 7 years ago

@hvr Thanks, I didn't catch that.

vagarenko commented 7 years ago

@hvr

just as a workaround, what if you use cabal --http-transport=plain-http update ?

This works, thanks. Adding wget or curl to Path also works.

@23Skidoo

I'd try debugging this by running the powershell download script manually.

Where can I find that script?

23Skidoo commented 7 years ago

@vagarenko It's assembled on the fly by the PowerShell transport. See here: https://github.com/haskell/cabal/blob/14c25d703a84e4c30f191f6a0b501d2c34a74479/cabal-install/Distribution/Client/HttpUtils.hs#L537

So I'd make it print out the script to stdout or a file, recompile cabal-install, and then try running the saved script by hand.

hvr commented 7 years ago

@23Skidoo I'm starting to wonder if the powershell transport ever worked...

gbaz commented 7 years ago

That log shows powershell-1.0 being used. I'm pretty sure the script only works with 2.0 or above. We could document this better, or add a test I suppose?

Here's a list of which powershell versions come with which oses https://4sysops.com/archives/powershell-versions-and-their-windows-version/#powershell-and-windows-versions

AndreasPK commented 6 years ago

This seems to be fixed in cabal-install-2.0.0.1

23Skidoo commented 6 years ago

Hmm, I wonder which commit fixed it. @AndreasPK can you actually reproduce the issue with 2.0.0.0?

AndreasPK commented 6 years ago

Not anymore.

I replaced the executable when I upgraded and if I rebuild it now it works. So either my executable was bogus or it was a change in the Environment.

Edit: When I rebuild cabal-install-2.0.0.0 now it works as well. So most likely a Environment issue in my case. I tried rebuilding it with Cabal 2.0.0.2, 2.0.1.0 and 2.0.1.1 as well so no can't really reproduce the issue anymore sadly.

23Skidoo commented 6 years ago

@AndreasPK Hmm, OK. Probably caused by wrong PowerShell version, as @gbaz says.

@gbaz Can we make using --transport=powershell an error when PowerShell's version is wrong?

AndreasPK commented 6 years ago

@23Skidoo

Edit: Fails on up to date cabal as well

... > cabal update -v3
no user package environment file found at
D:\Uni\03_bac\code\ghc_patterns\pattern_benchmarks
Downloading the latest package list from hackage.haskell.org
Searching for curl in path.
Cannot find curl on the path
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: powershell
Selected mirror http://hackage.haskell.org/
Downloading timestamp
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Downloading snapshot
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Updating index
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Exception dieVerbatim: user error (CallStack (from HasCallStack):
die', called at .\Distribution\Client\HttpUtils.hs:744:5 in
main:Distribution.Client.HttpUtils
cabal.exe: Failed to download http://hackage.haskell.org/01-index.tar.gz : No
Status Code could be parsed from response: An exception occurred during a
WebClient request.
) when using mirror http://hackage.haskell.org/
Selected mirror http://hackage.fpcomplete.com/
Downloading timestamp
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Downloading snapshot
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Updating index
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Exception dieVerbatim: user error (CallStack (from HasCallStack):
die', called at .\Distribution\Client\HttpUtils.hs:744:5 in
main:Distribution.Client.HttpUtils
cabal.exe: Failed to download http://hackage.fpcomplete.com/01-index.tar.gz :
No Status Code could be parsed from response: An exception occurred during a
WebClient request.
) when using mirror http://hackage.fpcomplete.com/
Selected mirror http://objects-us-west-1.dream.io/hackage-mirror/
Downloading timestamp
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Downloading snapshot
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
Updating index
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" "-InputFormat" "None" "-ExecutionPolicy" "bypass" "-NoProfile" "-NonInteractive" "-Command" "-"
dieVerbatim: user error (CallStack (from HasCallStack):
  die', called at .\Distribution\Client\HttpUtils.hs:744:5 in main:Distribution.Client.HttpUtils
cabal.exe: Failed to download
http://objects-us-west-1.dream.io/hackage-mirror/01-index.tar.gz : No Status
Code could be parsed from response: An exception occurred during a WebClient
request.
)

This is however on Windows10.

While the directory is called v1.0 the Powershell version is 5.1

$Host.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      16299  64

Cabal version:

cabal-install version 2.0.0.1
compiled using version 2.0.1.1 of the Cabal library
23Skidoo commented 6 years ago

@AndreasPK

$Host.Version

According to https://stackoverflow.com/questions/1825585/determine-installed-powershell-version, $Host.Version is not reliable and one should apparently use $PSVersionTable.PSVersion.

AndreasPK commented 6 years ago

@23Skidoo PSVersion reports the same version.

$PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      16299  64
digitalohm commented 6 years ago

same for

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      16299  248

cabal --http-transport=plain-http update did work

dlouwers commented 6 years ago

For me using cabal --http-transport=plain-http update broke it. cabal.exe got moved from AppData\Roaming\local\bin to AppData\Roaming\cabal\bin which isn't on the path. Workaround is to add a symlink %AppData%\local\bin\cabal.exe %AppData%\cabal\bin\cabal.exe.

hvr commented 6 years ago

for the record, the latest cabal-install-2.2.0.0 is supposed to have its powershell transport mode fixed and work out of the box as expected.

Annapooraniqxf2 commented 5 years ago

I couldn't update the cabal in windows 10. I am getting the below error

 cabal update
Warning: The update command is a part of the legacy v1 style of cabal usage.

Please switch to using either the new project style and the new-update command
or the legacy v1-update alias as new-style projects will become the default in
the next version of cabal-install. Please file a bug if you cannot replicate a
working v1- use case with the new-style commands.

For more information, see: https://wiki.haskell.org/Cabal/NewBuild

Downloading the latest package list from hackage.haskell.org
To revert to previous state run:
    cabal update --index-state='2019-10-16T11:31:42Z'

After updating the cabal and I have to install yesod.

fendor commented 5 years ago

@Annapooraniqxf2 That is not an error message, just a warning.

tysonzero commented 2 years ago

This error is showing up and preventing CircleCI+nix+Haskell builds for me on cabal-install-2.4.1.0.

fgaz commented 2 years ago

@tysonzero 2.4 is very old, could you update to 3.6?

tysonzero commented 2 years ago

@fgaz Possibly? We're locked on older versions of many things due to compile time perf regressions and TH bugs in GHCJS 8.10. Will get back to you.