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

GHCup selected combination of cabal / GHC versions does not work on windows #966

Closed
lmbollen opened this issue Jan 3, 2024 · 16 comments
Closed

Comments

@lmbollen
Copy link

lmbollen commented Jan 3, 2024

On Windows the default combination of versions for cabal and GHC do not support each other.
Reproducing steps:

  1. Install GHCup with proposed Powershell commands from Install page:
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $true } catch { Write-Error $_ }
  1. Verify that ghcup installed versions 3.6.2.0-p1 for cabal and 9.4.8 for ghc:
PS <path> ghcup list | findstr "IS"
[ Warn  ] New ghc version available. If you want to install this latest version, run 'ghcup install ghc 9.8.1'
[ Warn  ] New cabal version available. If you want to install this latest version, run 'ghcup install cabal 3.10.2.0'
[ Info  ] verifying digest of: gs.exe
IS ghc   9.4.8      recommended,base-4.17.2.1 hls-powered
IS cabal 3.6.2.0-p1 recommended
IS hls   2.5.0.0    latest,recommended
IS stack 2.13.1     latest,recommended
IS ghcup 0.1.20.0   latest,recommended
  1. Start a new project, e.g.:
    stack new my-clash-project clash-lang/simple
    Try to build it with cabal.
    cd my-clash-project
    cabal build
  2. receive warning:
PS path> cabal build
Warning: Unknown/unsupported 'ghc' version detected (Cabal 3.6.2.0 supports
'ghc' version < 9.4): C:\ghcup\bin\ghc.exe is version 9.4.8
Build profile: -w ghc-9.4.8 -O1
  1. failed build:
Failed to build parsers-0.12.11.
Build log (
C:\cabal\logs\ghc-9.4.8\parsers-0.12.11-646c18156e7e431ca0bcddc5dc3e70d2e4e5f445.log
):
Preprocessing library for parsers-0.12.11..
Building library for parsers-0.12.11..
[1 of 8] Compiling Text.Parser.Combinators ( src\Text\Parser\Combinators.hs, dist\build\Text\Parser\Combinators.o )
[2 of 8] Compiling Text.Parser.Char ( src\Text\Parser\Char.hs, dist\build\Text\Parser\Char.o )
ghc-9.4.8.exe: C:\cabal\store\ghc-9.4.8\hashable-1.4.3.0-6aa150cfd98536d070af2d7c96a3cc42751570fb\lib\libHShashable-1.4.3.0-6aa150cfd98536d070af2d7c96a3cc42751570fb.a(#7:LowLevel.o): Not a x86_64 PE+ file.
ghc-9.4.8.exe: Unknown COFF 4 type in getHeaderInfo.

<no location info>: error:
    loadArchive "C:\\cabal\\store\\ghc-9.4.8\\hashable-1.4.3.0-6aa150cfd98536d070af2d7c96a3cc42751570fb\\lib\\libHShashable-1.4.3.0-6aa150cfd98536d070af2d7c96a3cc42751570fb.a": failed
[3 of 8] Compiling Text.Parser.Expression ( src\Text\Parser\Expression.hs, dist\build\Text\Parser\Expression.o )
[4 of 8] Compiling Text.Parser.LookAhead ( src\Text\Parser\LookAhead.hs, dist\build\Text\Parser\LookAhead.o )
[5 of 8] Compiling Text.Parser.Permutation ( src\Text\Parser\Permutation.hs, dist\build\Text\Parser\Permutation.o )
[6 of 8] Compiling Text.Parser.Token.Highlight ( src\Text\Parser\Token\Highlight.hs, dist\build\Text\Parser\Token\Highlight.o )
cabal-3.6.2.0-p1.exe: Failed to build clash-prelude-1.8.1 (which is required
by test:test-library from my-clash-project-0.1, test:doctests from
my-clash-project-0.1 and others). The build process terminated with exit code
11
Failed to build parsers-0.12.11 (which is required by exe:clashi from
my-clash-project-0.1 and exe:clash from my-clash-project-0.1). See the build
log above for details.
@hasufell
Copy link
Member

hasufell commented Jan 3, 2024

https://gitlab.haskell.org/ghc/ghc/-/issues/21990#note_447802

We will have to backport haskell/cabal#8071 to 3.6 it seems. In the meantime, you can update to latest.

@hasufell
Copy link
Member

hasufell commented Jan 3, 2024

@lmbollen can you try this:

ghcup -s https://raw.githubusercontent.com/haskell/ghcup-metadata/cabal-3.6.2.0-p2/ghcup-0.0.8.yaml install cabal recommended

and then try to build your project again?

@lmbollen
Copy link
Author

lmbollen commented Jan 3, 2024

@hasufell
My previous fix was updating cabal to latest and GHC to 9.6.3.
I now reverted back to GHC 9.4.8, uninstalled all versions of cabal and ran your suggested command which results in the same versions for the tools.

PS path> ghcup list | findstr "IS"
[ Warn  ] New cabal version available. If you want to install this latest version, run 'ghcup install cabal 3.10.2.0'
[ Info  ] verifying digest of: gs.exe
IS ghc   9.4.8      recommended,base-4.17.2.1 hls-powered
IS cabal 3.6.2.0-p1 recommended
IS hls   2.5.0.0    latest,recommended
IS stack 2.13.1     latest,recommended
IS ghcup 0.1.20.0   latest,recommended

I do still get the same warning and the build still fails unfortunately.

@hasufell
Copy link
Member

hasufell commented Jan 3, 2024

I now reverted back to GHC 9.4.8, uninstalled all versions of cabal and ran your suggested command which results in the same versions for the tools.

That can't be. It has to show 3.6.2.0-p2 not 3.6.2.0-p1.

@lmbollen
Copy link
Author

lmbollen commented Jan 3, 2024

Well, it doesn't....

PS path> ghcup list | findstr "IS"
[ Warn  ] New cabal version available. If you want to install this latest version, run 'ghcup install cabal 3.10.2.0'
[ Info  ] verifying digest of: gs.exe
IS ghc   9.4.8      recommended,base-4.17.2.1 hls-powered
IS cabal 3.6.2.0-p1 recommended
IS hls   2.5.0.0    latest,recommended
IS stack 2.13.1     latest,recommended
IS ghcup 0.1.20.0   latest,recommended
PS path> ghcup rm cabal 3.6.2.0-p1
[ Warn  ] New cabal version available. If you want to install this latest version, run 'ghcup install cabal 3.10.2.0'
[ Info  ] verifying digest of: gs.exe
PS path> ghcup list | findstr "IS"
[ Info  ] verifying digest of: gs.exe
IS ghc   9.4.8      recommended,base-4.17.2.1 hls-powered
IS hls   2.5.0.0    latest,recommended
IS stack 2.13.1     latest,recommended
IS ghcup 0.1.20.0   latest,recommended
PS path> ghcup -s https://raw.githubusercontent.com/haskell/ghcup-metadata/cabal-3.6.2.0-p2/ghcup-0.0.8.yaml install cabal recommended
[ Info  ] verifying digest of: gs.exe
[ Info  ] downloading: https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal/3.6.2.1/cabal-install-3.6.2.1-x86_64-mingw64.zip as file C:\ghcup\tmp\ghcup-9f8013f960aa23be\cabal-install-3.6.2.1-x86_64-mingw64.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14.2M  100 14.2M    0     0  52.1M      0 --:--:-- --:--:-- --:--:-- 52.5M
[ Info  ] verifying digest of: cabal-install-3.6.2.1-x86_64-mingw64.zip
[ Info  ] Unpacking: cabal-install-3.6.2.1-x86_64-mingw64.zip to C:\ghcup\tmp\ghcup-b4d70b3ff48e9cef
[ Info  ] Installing cabal
[ Info  ] Cabal installation successful
[ Info  ] This is a distributor release to fix https://github.com/haskell/security-advisories/blob/main/advisories/hackage/cabal-install/HSEC-2023-0015.md
[ ...   ] The applied downstream patches can be viewed here: https://github.com/hasufell/cabal/tree/cabal-install-v3.6.2.1
[ ...   ] Upstream PR: https://github.com/haskell/cabal/issues/9451
[ ...   ] You can alternatively update to 3.10.2.0.
[ ...   ]
PS path> ghcup list | findstr "IS"
[ Warn  ] New cabal version available. If you want to install this latest version, run 'ghcup install cabal 3.10.2.0'
[ Info  ] verifying digest of: gs.exe
IS ghc   9.4.8      recommended,base-4.17.2.1 hls-powered
IS cabal 3.6.2.0-p1 recommended
IS hls   2.5.0.0    latest,recommended
IS stack 2.13.1     latest,recommended
IS ghcup 0.1.20.0   latest,recommended

Let me know if I'm missing something :)

@hasufell
Copy link
Member

hasufell commented Jan 3, 2024

Please run ghcup gc -c first. It's not downloading the new metadata.

@lmbollen
Copy link
Author

lmbollen commented Jan 3, 2024

Now I do get p2, but I still get the warning and failed build:

PS path> ghcup list | findstr "IS"
[ Warn  ] New cabal version available. If you want to install this latest version, run 'ghcup install cabal 3.10.2.0'
[ Info  ] verifying digest of: gs.exe
IS ghc   9.4.8      recommended,base-4.17.2.1 hls-powered
IS cabal 3.6.2.0-p2 recommended
IS hls   2.5.0.0    latest,recommended
IS stack 2.13.1     latest,recommended
IS ghcup 0.1.20.0   latest,recommended
PS path> cabal clean
PS path> cabal build
Warning: Unknown/unsupported 'ghc' version detected (Cabal 3.6.2.0 supports
'ghc' version < 9.4): C:\ghcup\bin\ghc.exe is version 9.4.8
Resolving dependencies...
Build profile: -w ghc-9.4.8 -O1
In order, the following will be built (use -v for more details):
 - clash-prelude-1.8.1 (lib) (requires build)
 - parsers-0.12.11 (lib) (requires build)
 - my-clash-project-0.1 (lib) (first run)
 - trifecta-2.1.3 (lib) (requires build)
 - my-clash-project-0.1 (test:test-library) (first run)
 - my-clash-project-0.1 (test:doctests) (first run)
 - clash-lib-1.8.1 (lib) (requires build)
 - clash-ghc-1.8.1 (lib) (requires build)
 - my-clash-project-0.1 (exe:clashi) (first run)
 - my-clash-project-0.1 (exe:clash) (first run)
Starting     parsers-0.12.11 (lib)
Starting     clash-prelude-1.8.1 (lib)
Building     parsers-0.12.11 (lib)
Building     clash-prelude-1.8.1 (lib)

Failed to build parsers-0.12.11.
Build log (
C:\cabal\logs\ghc-9.4.8\parsers-0.12.11-646c18156e7e431ca0bcddc5dc3e70d2e4e5f445.log
):
Preprocessing library for parsers-0.12.11..
Building library for parsers-0.12.11..
[1 of 8] Compiling Text.Parser.Combinators ( src\Text\Parser\Combinators.hs, dist\build\Text\Parser\Combinators.o )
[2 of 8] Compiling Text.Parser.Char ( src\Text\Parser\Char.hs, dist\build\Text\Parser\Char.o )
ghc-9.4.8.exe: C:\cabal\store\ghc-9.4.8\hashable-1.4.3.0-6aa150cfd98536d070af2d7c96a3cc42751570fb\lib\libHShashable-1.4.3.0-6aa150cfd98536d070af2d7c96a3cc42751570fb.a(#7:LowLevel.o): Not a x86_64 PE+ file.
ghc-9.4.8.exe: Unknown COFF 4 type in getHeaderInfo.

<no location info>: error:
    loadArchive "C:\\cabal\\store\\ghc-9.4.8\\hashable-1.4.3.0-6aa150cfd98536d070af2d7c96a3cc42751570fb\\lib\\libHShashable-1.4.3.0-6aa150cfd98536d070af2d7c96a3cc42751570fb.a": failed
[3 of 8] Compiling Text.Parser.Expression ( src\Text\Parser\Expression.hs, dist\build\Text\Parser\Expression.o )
[4 of 8] Compiling Text.Parser.LookAhead ( src\Text\Parser\LookAhead.hs, dist\build\Text\Parser\LookAhead.o )
[5 of 8] Compiling Text.Parser.Permutation ( src\Text\Parser\Permutation.hs, dist\build\Text\Parser\Permutation.o )
[6 of 8] Compiling Text.Parser.Token.Highlight ( src\Text\Parser\Token\Highlight.hs, dist\build\Text\Parser\Token\Highlight.o )
cabal-3.6.2.0-p2.exe: Failed to build clash-prelude-1.8.1 (which is required
by test:test-library from my-clash-project-0.1, test:doctests from
my-clash-project-0.1 and others). The build process terminated with exit code
11
Failed to build parsers-0.12.11 (which is required by exe:clashi from
my-clash-project-0.1 and exe:clash from my-clash-project-0.1). See the build
log above for details.

@hasufell
Copy link
Member

hasufell commented Jan 3, 2024

You may need to run cabal clean first and delete the possibly corrupted store at C:\cabal\store\ghc-9.4.8.

@hasufell
Copy link
Member

hasufell commented Jan 3, 2024

The problem is, I can't reproduce it. I get different errors, possibly due to corrupted toolchain or environment.

@lmbollen
Copy link
Author

lmbollen commented Jan 3, 2024

It was indeed the corrupted store. HLS also works with this configuration.

@hasufell
Copy link
Member

hasufell commented Jan 3, 2024

Thanks for testing

@lmbollen
Copy link
Author

lmbollen commented Jan 3, 2024

Oh I do still get the warning.

@hasufell
Copy link
Member

hasufell commented Jan 3, 2024

Oh I do still get the warning.

Yeah, I didn't bother removing it. It can be ignored

@hasufell
Copy link
Member

hasufell commented Jan 3, 2024

I'm still in the process of gathering info from upstream whether I've missed something before I release the patch release into ghcup proper.

Meanwhile, the 'develop' channel covers this, you can set it in your config under ~/.ghcup/config.yaml:

url-source:
- https://raw.githubusercontent.com/haskell/ghcup-metadata/develop/ghcup-0.0.8.yaml

hasufell added a commit to haskell/ghcup-metadata that referenced this issue Jan 4, 2024
Related:

* haskell/ghcup-hs#966

We bump this, although 'cabal run' is known to be broken
on windows: haskell/cabal#9334

However, backporting more patches to 3.6 is not sustainable.
Initially, I tried to backport
haskell/cabal#8071,
but it's not clear whether that is the only thing that causes
compatibility issues with GHC 9.4 and might drive us into
an awkward situation as well.
@hasufell
Copy link
Member

hasufell commented Jan 4, 2024

I decided it's not worth to do more backports and set cabal-3.10.2.1 as recommended despite a known regression. 3.10.3.0 is supposed to fix that and may come soon.

haskell/ghcup-metadata@dd975d6

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

No branches or pull requests

2 participants