Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

GHC version on Windows is not selected correctly #245

Closed
ulysses4ever opened this issue May 3, 2023 · 14 comments · Fixed by #246
Closed

GHC version on Windows is not selected correctly #245

ulysses4ever opened this issue May 3, 2023 · 14 comments · Fixed by #246
Assignees
Labels
bug Something isn't working platform: windows re: choco Concerning installation via chocolatey (windows) re: ghcup Concerning setup using ghcup
Milestone

Comments

@ulysses4ever
Copy link
Contributor

Consider this run on Cabal CI and in particular the step where haskell/action tries to setup GHC 9.4.4.

Installing ghc version 9.4.4
  C:\ghcup\bin\ghcup.exe whereis ghc 9.4.4
  [ Error ] [�
  
  
  Attempting to access tool ghc at location <not-found>
  Failed to access tool ghc at location <not-found>
  Attempting to access tool ghc at location C:/ghcup/bin
  Succeeded accessing tool ghc at location C:/ghcup/bin
  C:\ghcup\bin\ghcup.exe set ghc 9.4.4
  [ Info  ] downloading: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.7.yaml as file C:\ghcup\cache\ghcup-0.0.7.yaml
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
  
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  [ Info  ] verifying digest of: gs.exe
  [ Error ] [�
  Attempting to install ghc 9.4.4 using chocolatey
  ::stop-commands::***
  C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe choco install ghc --version 9.4.4 --allow-multiple-versions --ignore-dependencies --no-progress --limit-output
  Installing the same package with multiple versions is deprecated and will be removed in v2.0.0.
  Installing the following packages:
  ghc
  By installing, you accept licenses for the packages.
  
  ghc v9.4.4 [Approved]
  ghc package files install completed. Performing other installation steps.
  Downloading ghc 64 bit
    from 'https://downloads.haskell.org/~ghc/9.4.4/ghc-9.4.4-x86_64-unknown-mingw32.tar.xz'
  
  Download of ghcInstall (265.92 MB) completed.
  Hashes match.
  C:\tools\ghc-9.4.4\tmp\ghcInstall
  Extracting C:\tools\ghc-9.4.4\tmp\ghcInstall to C:\tools...
  C:\tools
  Extracting C:\tools\ghcInstall~ to C:\tools...
  C:\tools
  Renamed C:\tools\ghc-9.4.4-x86_64-unknown-mingw32 to C:\tools\ghc-9.4.4
  PATH environment variable does not have C:\tools\ghc-9.4.4\bin in it. Adding...
  Hiding shims for 'C:\tools'.
  Environment Vars (like PATH) have changed. Close/reopen your shell to
   see the changes (or in powershell/cmd.exe just type `refreshenv`).
   The install of ghc was successful.
    Software installed to 'C:\tools'
  
  Chocolatey installed 1/1 packages. 
   See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
  ::***::
  C:\ghcup\bin\ghcup.exe whereis ghc 9.4.4
  [ Error ] [�
  
  
  Attempting to access tool ghc at location C:\tools\ghc-9.4.4\bin
  Succeeded accessing tool ghc at location C:\tools\ghc-9.4.4\bin
  Found ghc 9.4.4 in cache at path C:\tools\ghc-9.4.4\bin. Setup successful.

So,

  1. ghcup spits some errors (is it expected?) and then calls choco to install 9.4.4
  2. choco seems to succeed in installing GHC 9.4.4
  3. as seen in a later step where we print versions of tools, we end up with GHC 9.6.1 in the path. Presumably that's what ghcup installed by default. This is wrong (we asked for 9.4.4)
@jneira
Copy link
Member

jneira commented May 3, 2023

Great analysis,
printing the PATH would confirm defintely the hypothesis and well one solution could be mutate again the PATH and see if the action wins the race :P

@andreasabel
Copy link
Member

Weird, why is this test not failing then? https://github.com/haskell/actions/actions/runs/4854045876/jobs/8650938147

@ulysses4ever
Copy link
Contributor Author

@andreasabel no idea but could 9.4.4 be special somehow? You reference a job called "Add GHC 9.4.5", and it adds 9.4.3, I think. So, not 9.4.4.

Meanwhile, by Javier's advice, I printed the $PATH, and indeed ghcup goes before Chocolatey:

/mingw64/bin
/usr/bin
/c/Users/runneradmin/bin
/c/ghcup/bin
/c/tools/ghc-9.4.4/bin
/c/Program Files/MongoDB/Server/5.0/bin
/c/aliyun-cli
/c/vcpkg
/c/Program Files (x86)/NSIS
/c/tools/zstd
/c/Program Files/Mercurial
/c/hostedtoolcache/windows/stack/2.9.3/x64
/c/cabal/bin
/c/ghcup/bin
/c/Program Files/dotnet
/c/mysql/bin
/c/Program Files/R/R-4.3.0/bin/x64
/c/SeleniumWebDrivers/GeckoDriver
/c/Program Files (x86)/sbt/bin
/c/Program Files (x86)/GitHub CLI
/bin
/c/Program Files (x86)/pipx_bin
/c/npm/prefix
/c/hostedtoolcache/windows/go/1.20.3/x64/bin
/c/hostedtoolcache/windows/Python/3.9.13/x64/Scripts
/c/hostedtoolcache/windows/Python/3.9.13/x64
/c/hostedtoolcache/windows/Ruby/3.0.6/x64/bin
/c/Program Files/OpenSSL/bin
/c/tools/kotlinc/bin
/c/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/8.0.372-7/x64/bin
/c/Program Files/ImageMagick-7.1.1-Q16-HDRI
/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin
/c/ProgramData/kind
/c/Program Files/Microsoft/jdk-11.0.16.101-hotspot/bin
/c/Windows/system32
/c/Windows
/c/Windows/System32/Wbem
/c/Windows/System32/WindowsPowerShell/v1.0
/c/Windows/System32/OpenSSH
/c/Program Files/dotnet
/c/ProgramData/Chocolatey/bin
/c/Program Files/PowerShell/7
/c/Program Files/Microsoft/Web Platform Installer
/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn
/c/Program Files/Microsoft SQL Server/150/Tools/Binn
/c/Strawberry/c/bin
/c/Strawberry/perl/site/bin
/c/Strawberry/perl/bin
/c/ProgramData/chocolatey/lib/pulumi/tools/Pulumi/bin
/c/Program Files/TortoiseSVN/bin
/c/Program Files/CMake/bin
/c/ProgramData/chocolatey/lib/maven/apache-maven-3.8.7/bin
/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code
/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager
/c/Program Files/nodejs
/cmd
/mingw64/bin
/usr/bin
/c/Program Files/GitHub CLI
/c/tools/php
/c/Program Files (x86)/sbt/bin
/c/SeleniumWebDrivers/ChromeDriver
/c/SeleniumWebDrivers/EdgeDriver
/c/Program Files/Amazon/AWSCLIV2
/c/Program Files/Amazon/SessionManagerPlugin/bin
/c/Program Files/Amazon/AWSSAMCLI/bin
/c/Program Files/Microsoft SQL Server/130/Tools/Binn
/c/Program Files/LLVM/bin
/c/Users/runneradmin/.dotnet/tools
/c/Users/runneradmin/.cargo/bin
/c/Users/runneradmin/AppData/Local/Microsoft/WindowsApps

Is it possible to ask ghcup not to install the default GHC, maybe? That's just my uneducated guess...

@andreasabel
Copy link
Member

andreasabel commented May 3, 2023

@ulysses4ever wrote:

  1. ghcup spits some errors (is it expected?)

Yes, as it does not find 9.4.4, it reports errors.

and then calls choco to install 9.4.4

The action then calls choco, indeed.

Maybe the logical step that is missing before calling choco is ghcup unset ghc to make sure no preinstalled GHC is taking prio over the choco installed one.

@ulysses4ever
Copy link
Contributor Author

Maybe the logical step that is missing before calling choco is ghcup unset ghc to make sure no preinstalled GHC is taking prio over the choco installed one.

Yes, that sounds exactly right to me.

@andreasabel
Copy link
Member

@ulysses4ever : Could you test #246?
You need to use haskell/actions/setup@issue-245.

@ulysses4ever
Copy link
Contributor Author

ulysses4ever commented May 3, 2023

I'm sorry but is it haskell/actions/setup@issue-245 or haskell/actions/setup@pr-246?

@ulysses4ever
Copy link
Contributor Author

here's the run with what you said: https://github.com/haskell/cabal/actions/runs/4875978697/jobs/8698883501?pr=8934

@andreasabel
Copy link
Member

andreasabel commented May 3, 2023

here's the run with what you said: haskell/cabal/actions/runs/4875978697/jobs/8698883501?pr=8934

Seems to work: https://github.com/haskell/cabal/actions/runs/4875978697/jobs/8698883501?pr=8934#step:7:12
(uses 9.4.4 now, used 9.6.1 before)

@ulysses4ever
Copy link
Contributor Author

@andreasabel yes!

@andreasabel andreasabel added this to the 2.3.9 milestone May 3, 2023
@andreasabel andreasabel added bug Something isn't working platform: windows re: ghcup Concerning setup using ghcup re: choco Concerning installation via chocolatey (windows) labels May 3, 2023
@andreasabel andreasabel self-assigned this May 3, 2023
@andreasabel
Copy link
Member

Ok, I'll release this as 2.3.9.

@andreasabel
Copy link
Member

With 9.4.4 and cabal 3.10.1.0 instead of 9.4.3 and cabal 3.8, I can reproduce this locally: https://github.com/haskell/actions/actions/runs/4876106161/jobs/8699177636?pr=247
Can't say I understand the subtleties...

andreasabel added a commit that referenced this issue May 3, 2023
The existing case Windows / GHC 9.4.3 / Cabal 3.8 did not catch this.
@ulysses4ever
Copy link
Contributor Author

Amazing work! Thank you Andreas for the swift fix and thanks Javier for pitching in ideas for how to investigate!

@andreasabel
Copy link
Member

Thanks for early testing and reporting, @ulysses4ever !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working platform: windows re: choco Concerning installation via chocolatey (windows) re: ghcup Concerning setup using ghcup
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants