Skip to content

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

Closed

Description

@nh2

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

Activity

  1. nh2 commented on Apr 27, 2018

    @nh2
    CollaboratorAuthor

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

  2. nh2 commented on Apr 27, 2018

    @nh2
    CollaboratorAuthor

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

  3. nh2 commented on Apr 27, 2018

    @nh2
    CollaboratorAuthor

    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
    
  4. nh2 commented on Apr 28, 2018

    @nh2
    CollaboratorAuthor

    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.

  5. snoyberg commented on Apr 2, 2019

    @snoyberg
    Contributor

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

  6. added a commit that references this issue on Sep 10, 2022
  7. mpilgrem commented on Sep 10, 2022

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions