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

stack fails unpacking ghc on Windows under non-ASCII path because 7zip version is too old #3987

Closed
Tracked by #3988
nh2 opened this issue Apr 27, 2018 · 6 comments
Closed
Tracked by #3988

Comments

@nh2
Copy link
Collaborator

nh2 commented Apr 27, 2018

When on Windows my user name is set to and I want to stack runghc a file, the 7z invocation issued by stack fails with the message:

PS C:\csl> stack --stack-root C:\sr --work-dir .w runghc -- .\log-warper-test.hs
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.
Already downloaded.
Already downloaded.

7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18


Error:
7-Zip cannot find the code that works with archives.
Problem while decompressing C:\Users\µùÑ\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2.tar.xz

Confirming it's a 7zip problem by directly invoking it:

```PS C:\csl> C:\Users\日\AppData\Local\Programs\stack\x86_64-windows\7z.exe l C:\Users\日\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2.tar.xz

7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18


Error:
7-Zip cannot find the code that works with archives.```

@bitemyapp got the great idea to check how old that 7zip version obtained by stack is.

It is version 9.20, which as per https://www.7-zip.org/download.html is from 2010-11-18. Indeed using the newer version 18.01 fixes it:

PS C:\csl> & 'C:\Program Files\7-Zip\7z.exe' l C:\Users\日\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2.tar.xz

7-Zip 18.01 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-01-28

Scanning the drive for archives:
1 file, 152282428 bytes (146 MiB)

Listing archive: C:\Users\_\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2.tar.xz
...

Stack version

$ stack --version
Version 1.6.5, Git revision 24ab0d6ff07f28276e082c3ce74dfdeb1a2ca9e9 (5514 commits) x86_64 hpack-0.20.0

Method of installation

  • Official Windows binary, downloaded from haskellstack.org
@nh2
Copy link
Collaborator Author

nh2 commented Apr 27, 2018

We should make stack use a newer version of 7zip to fix this issue.

@nh2
Copy link
Collaborator Author

nh2 commented Apr 27, 2018

This issue was found as part of the effort to make stack work great under non-ASCII user names: #3988

@nh2
Copy link
Collaborator Author

nh2 commented Apr 27, 2018

I also tried with xz from the Windows binary distribution from xzutils (https://tukaani.org/xz/), just to check whether we should maybe use that one instead of 7zip in general, but in contrast to the latest version of 7zip, the latest version of that one doesn't work:

PS C:\csl> C:\xz_extracted\bin_x86-64\xz.exe -l C:\Users\日\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2.tar.xz
xz: C:\Users\?\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2.tar.xz: Invalid argument

Version is:

PS C:\Users\日\stack-test> C:\xz_extracted\bin_x86-64\xz.exe --version
xz (XZ Utils) 5.2.3
liblzma 5.2.3

@nh2
Copy link
Collaborator Author

nh2 commented Apr 28, 2018

I can confirm that upgrading 7z to 18.01 works with stack.

I've saved https://github.com/fpco/stackage-content/blob/edc62c118a7319e6dcd1b39ccf1723e0b5f062d3/stack/stack-setup-2.yaml as stack-setup-info.yaml and adjusted the following sections to contain links to 7z.exe and 7z.dll version 18.01:

sevenzexe-info:
    url: "http://nh2.me/7z/7z.exe"
    content-length: 455168
    sha1: 596297deacf9a1815cefd46d1ac52aa5672ed2bd
sevenzdll-info:
    url: "http://nh2.me/7z/7z.dll"
    content-length: 1656832
    sha1: ef6a002f0defd1a3320d6f04a0c87bcb63d5672c

Then I ran:

PS C:\Users\日\stack-test> stack setup --stack-setup-yaml .\stack-setup-info.yaml
Warning: .\stack-setup-info.yaml: Unrecognized field in GHCDownloadInfo: version
Warning: .\stack-setup-info.yaml: Unrecognized field in SetupInfo: portable-git
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.
7z.dll:   35.40 KiB / 1.58 MiB (  2.19%) downloaded...Download expectation failure: content hash (SHA1)
Expected: 168a288d4456f0473f66e86a2d6fec4eb6f4b99a (ByteString)
Actual:   ef6a002f0defd1a3320d6f04a0c87bcb63d5672c
For: http://nh2.me:80/7z/7z.dll
PS C:\Users\日\stack-test> stack setup --stack-setup-yaml .\stack-setup-info.yaml
Warning: .\stack-setup-info.yaml: Unrecognized field in GHCDownloadInfo: version
Warning: .\stack-setup-info.yaml: Unrecognized field in SetupInfo: portable-git
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.
Downloaded 7z.dll.
Preparing to download 7z.exe ...Download expectation failure: ContentLength header
Expected: 73728
Actual:   455168
For: http://nh2.me:80/7z/7z.exe
PS C:\Users\日\stack-test> stack setup --stack-setup-yaml .\stack-setup-info.yaml
Warning: .\stack-setup-info.yaml: Unrecognized field in GHCDownloadInfo: version
Warning: .\stack-setup-info.yaml: Unrecognized field in SetupInfo: portable-git
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.
Already downloaded.
Downloaded 7z.exe.

7-Zip 18.01 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-01-28

Scanning the drive for archives:
1 file, 152282428 bytes (146 MiB)

Extracting archive: C:\Users\_\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2.tar.xz
--
Path = C:\Users\_\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2.tar.xz
Type = xz
Physical Size = 152282428
Method = LZMA2:23 CRC64
Streams = 1
Blocks = 1

Everything is Ok

Size:       1435248640
Compressed: 152282428

7-Zip 18.01 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-01-28

Scanning the drive for archives:
1 file, 1435248640 bytes (1369 MiB)

Extracting archive: C:\Users\_\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2-tmp22080\ghc-8.0.2.tar
--
Path = C:\Users\_\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2-tmp22080\ghc-8.0.2.tar
Type = tar
Physical Size = 1435248640
Headers Size = 4755968
Code Page = UTF-8

Everything is Ok

Folders: 408
Files: 8819
Size:       1428273210
Compressed: 1435248640
GHC installed to C:\Users\?\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\
The GHC located at C:\Users\µùÑ\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\bin\ghc.EXE failed to compile a sa
nity check. Please see:

    http://docs.haskellstack.org/en/stable/install_and_upgrade/

for more information. Exception was:
Running C:\Users\µùÑ\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\bin\ghc.EXE C:\Users\µùÑ\AppData\Local\Temp\2
\stack-sanity-check22080\Main.hs -no-user-package-db in directory C:\Users\µùÑ\AppData\Local\Temp\2\stack-sanity-check22
080\ exited with ExitFailure 1

[1 of 1] Compiling Main             ( C:\Users\?\AppData\Local\Temp\2\stack-sanity-check22080\Main.hs, C:\Users\?\AppDat
a\Local\Temp\2\stack-sanity-check22080\Main.o )


<no location info>: error:
    Warning: Couldn't figure out C compiler information!
             Make sure you're using GNU gcc, or clang
Unable to start C:\Users\?\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\mingw\bin/realgcc.exe (error code: 123)
`gcc.exe' failed in phase `Assembler'. (Exit code: 1)

The output of the new 7z version seems to be more verbose, we might want to pass a flag if we don't like that. But that's not so important to me.

The error at the end is a separate issue.

@snoyberg
Copy link
Contributor

snoyberg commented Apr 2, 2019

Can you open up a PR to include the newer version?

mpilgrem added a commit to commercialhaskell/stackage-content that referenced this issue Sep 10, 2022
Also moves location of Stack-supplied 7-Zip files to be consistent with that of MSYS2 files.

7z.exe and 7z.dll originally obtained from https://www.7-zip.org/download.html.

Addresses Stack issue [#3987](commercialhaskell/stack#3987).

Tested before committing with a local setup-info dictionary.
@mpilgrem
Copy link
Member

@nh2, I have updated the Stack-supplied 7-Zip to 7-Zip 22.01. You will have to delete the existing 7z.exe and 7z.dll in your stack path --programs directory, in order for Stack to be prompted to fetch the updated 7-Zip version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants