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

Consider ghcup for windows #70

Closed

Description

@hasufell

Right now, when I define

jobs:
  build-cabal:

    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macOS-latest, windows-latest]
        ghc: ['8.10.7', '9.0.1']
        cabal: ['3.4.0.0']

This will fail on windows only, because 8.10.7 isn't in choco yet. It's quite confusing, because different installers with different release schedules are used under the hood.

I merged https://gitlab.haskell.org/haskell/ghcup-hs/-/merge_requests/159 which would allow the installation procedure on windows to be:

curl.exe -O https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1
.\bootstrap-haskell.ps1 -InstallDir 'C:\' -InBash -Minimal

Leaving you with an msys2 installation (in C:\ghcup\msys64) and the ghcup binary (in C:\ghcup\bin), nothing more.

Installations of msys2 packages would be carried out via:

C:\ghcup\msys64\usr\bin\bash.exe -lc 'pacman --noconfirm -S package'

Activity

  1. hazelweakly commented on Sep 1, 2021

    @hazelweakly
    Collaborator

    I think the windows images from GitHub still use chocolatey under the hood, so I would still default to that (for fastest setup time in the cloud), but I'm looking forward to being able to fall back to ghcup on Windows and possibly even switch to using it first if the action images start using ghcup for windows too.

    PRs are more than welcome for the functionality, but otherwise I'll try to get around to it when time permits over the next few weeks :)

    (Edit: in case it wasn't clear, I deeply appreciate the windows support in ghcup. It's something I've been looking forward to for a long time and I'm super stoked about it. Thanks for all your work in the Haskell tooling space!)

  2. hasufell commented on Sep 1, 2021

    @hasufell
    MemberAuthor

    for fastest setup time in the cloud

    Good point. I timed that and from my tests ghcup is twice as fast: https://github.com/hasufell/shortbytestring/runs/3487178253?check_suite_focus=true#step:3:1

    Takes 2m5s and installs ghcup, cabal, ghc and msys2

          Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $false 

    Takes 3m59s and installs cabal, ghc and msys2

        choco install -y haskell-dev 

    Does the haskell action do anything different that would make chocolatey faster?

  3. jneira commented on Sep 3, 2021

    @jneira
    Member

    I think the windows images from GitHub still use chocolatey under the hood,

    confirmed: https://github.com/actions/virtual-environments/blob/main/images/win/scripts/Installers/Install-Haskell.ps1

    linux/macos uses the package manager (ppa/hvr) for ghc and ghcup for cabal, it seems the ghc installed by ghcup is bigger than the other one (???):

    # We are using apt-get to install ghc, not ghcup,
    # because ghc installed through ghcup takes up too much disk space (2GB versus 1GB through apt-get)

    https://github.com/actions/virtual-environments/blob/ec9ac010f114131adacb246cf87c8127c19aa0d9/images/linux/scripts/installers/haskell.sh#L33

    I think @maerwald will find that interesting 😉

  4. hasufell commented on Sep 3, 2021

    @hasufell
    MemberAuthor

    linux/macos uses the package manager (ppa/hvr) for ghc and ghcup for cabal, it seems the ghc installed by ghcup is bigger than the other one (???):

    I'm not sure how that's relevant to the windows discussion?

    (The reason is that the apt repository has debug symbols and documentation separate. The GHC build system doesn't allow that split. It has to be done manually.)

  5. jneira commented on Sep 3, 2021

    @jneira
    Member

    I'm not sure how that's relevant to the windows discussion?

    Well if linux/macos already would use ghcup for ghc (even as fallback) it would be more appealing for gha unify all the three os's through ghcup

  6. jneira commented on Sep 3, 2021

    @jneira
    Member

    In fact upstreaming the actual haskell actions ghc/cabal/stack setup logic to gha vms would be great by itself

  7. hasufell commented on Sep 3, 2021

    @hasufell
    MemberAuthor

    Well if linux/macos already would use ghcup for ghc (even as fallback) it would be more appealing for gha unify all the three os's through ghcup

    I don't understand. I thought haskell/actions already does use ghcup for linux and mac. I have no idea about actions/virtual-environments and currently don't have plans to use it. This ticket is about this action only.

  8. jneira commented on Sep 3, 2021

    @jneira
    Member

    hmm actions/virtual-environments are the actual vms where gha (so haskell/actions) are being run. Afaik (maybe @jared-w could correct me if i am wrong) those vms have already installed the haskell toolchain and haskell/actions does a fallback over such preinstalled toolchain (as it can be obsolete for some time)

    but yeah we can ignore upstream 🙂

  9. hasufell commented on Sep 3, 2021

    @hasufell
    MemberAuthor

    hmm actions/virtual-environments are the actual vms where gha (so haskell/actions) are being run.

    Ah. I wasn't aware. Well, then my suggestion is to simply tell ghcup where the pre-installed msys2 is. Then the installation will take only a couple of seconds.

  10. jneira commented on Sep 3, 2021

    @jneira
    Member

    as it can be obsolete for some time

    Also it does not install all ghc versions, only 2 latest Haskell Major.Minor versions so haskell/action installs the other ones if requested. But the build would be faster if you use the preinstalled ones and they will be more up to date if they use ghcup :-)

  11. hasufell commented on Sep 3, 2021

    @hasufell
    MemberAuthor

    So we can use the pre-installed msys2 via:

    Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $false, $true, $true, $false, $false, $false, $false, C:\, "", C:\msys64, C:\cabal

    This takes 15 seconds to install ghcup: https://github.com/hasufell/shortbytestring/runs/3506845639?check_suite_focus=true#step:3:1

  12. hasufell commented on Sep 3, 2021

    @hasufell
    MemberAuthor
  13. newhoggy commented on Sep 5, 2021

    @newhoggy
    Contributor

    Also worth considering that Chocolatey is fairly unreliable. For example, I just witnessed this failure on Windows:

    Run haskell/actions/setup@v1
    Preparing to setup a Haskell environment
    Installing ghc version 8.10.4
      Attempting to install ghc 8.10.4 using chocolatey
      ::stop-commands::SetupHaskellStopCommands
      C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe choco install ghc --version 8.10.4 -m --no-progress -r
      Installing the following packages:
      ghc
      By installing you accept licenses for the packages.
      [NuGet] Could not connect to the feed specified at 'https://community.chocolatey.org/api/v2/'. Please verify that the package source (located in the Package Manager Settings) is valid and ensure your network connectivity.
      ghc not installed. An error occurred during installation:
       Unable to resolve dependency 'cabal (≥ 3.2.0.0)'.
      ghc package files install completed. Performing other installation steps.
      The install of ghc was NOT successful.
      ghc not installed. An error occurred during installation:
       Unable to resolve dependency 'cabal (≥ 3.2.0.0)'.
      
      Chocolatey installed 0/1 packages. 1 packages failed.
       See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
      
      Failures
       - ghc (exited 1) - ghc not installed. An error occurred during installation:
       Unable to resolve dependency 'cabal (≥ 3.2.0.0)'.
      C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe choco install ghc --version 8.10.4 -m --no-progress -r --pre
      Installing the following packages:
      ghc
      By installing you accept licenses for the packages.
      ghc not installed. An error occurred during installation:
       The operation has timed out
      ghc package files install completed. Performing other installation steps.
      The install of ghc was NOT successful.
      ghc not installed. An error occurred during installation:
       The operation has timed out
      
      Chocolatey installed 0/1 packages. 1 packages failed.
       See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
      
      Failures
       - ghc (exited 1) - ghc not installed. An error occurred during installation:
       The operation has timed out
      ::SetupHaskellStopCommands::
    Error: All install methods for ghc 8.10.4 failed
    

    Reliability trumps installation speed in CI.

  14. jneira commented on Sep 5, 2021

    @jneira
    Member

    yeah in hls we experienced that issue with choco lately 😕

  15. 21 remaining items

  16. jneira commented on Mar 10, 2022

    @jneira
    Member

    I still think use ghcup in this action would make sense. You can also use chocolatey or hvr/ppa outside this action but it allows workflows abstract away from the concrete channels and the future changes in them.
    It will make handling across all os's more uniform.

  17. andreasabel commented on Mar 15, 2022

    @andreasabel
    Member

    @hasufell

    And in fact, that's what I do in filepath: haskell/filepath@4638d2a/.github/workflows/test.yaml#L58

    This CI does not demonstrate caching of dependencies. How do communicate the cabal store directory in a stable way without setup-haskell?
    This would be a typical caching phase:

        - uses: actions/cache@v2
          with:
            path: ${{ steps.setup-haskell.outputs.cabal-store }}
            # The file `plan.json` contains the build information.
            key: ${{ runner.os }}-${{ env.GHC_VER }}-${{ env.CABAL_VER }}-${{ hashFiles('**/plan.json') }}
    
  18. newhoggy commented on Mar 15, 2022

    @newhoggy
    Contributor

    I feel like cabal should have a command to print where the cabal store is since it already knows where it is.

  19. andreasabel commented on Mar 15, 2022

    @andreasabel
    Member

    I feel like cabal should have a command to print where the cabal store is since it already knows where it is.

    Is there already a cabal issue for this? If not please report, linking here!

  20. jneira commented on Mar 15, 2022

    @jneira
    Member

    It seems to me that the incoming cabal status could give that info: haskell/cabal#7500

    An usual workaround is tell cabal use a specific store dir, changing the global config using cabal init and use that specific path in the cache step. Not ideal but you have to do it for windows anyways to workaround the max path length issue.

    https://github.com/haskell/cabal/blob/906a8bcabc307c6c607cf1b9826a6b329e3ceb7f/.github/workflows/windows.yml#L37

    However chocolatey already sets the store dir in C:\sr and ghcup in X:\cabal\store and the setup action gives it to you.

  21. hasufell commented on Mar 15, 2022

    @hasufell
    MemberAuthor

    @hasufell

    And in fact, that's what I do in filepath: haskell/filepath@4638d2a/.github/workflows/test.yaml#L58

    This CI does not demonstrate caching of dependencies. How do communicate the cabal store directory in a stable way without setup-haskell? This would be a typical caching phase:

        - uses: actions/cache@v2
          with:
            path: ${{ steps.setup-haskell.outputs.cabal-store }}
            # The file `plan.json` contains the build information.
            key: ${{ runner.os }}-${{ env.GHC_VER }}-${{ env.CABAL_VER }}-${{ hashFiles('**/plan.json') }}
    

    I would actually suggest using https://github.com/haskell-works/cabal-cache ...it allows syncing to a directory (instead of S3). Then you would tell actions/cache@v2 to just cache that directory. That may also save some cache space, because it only caches the needed libraries from the resolution.

    I can code up an example if I have a bit more time.

  22. added
    re: ghcup
    on Dec 22, 2022
  23. andreasabel commented on Feb 18, 2023

    @andreasabel
    Member

    Work on this is going on in a fork: main...wz1000:actions:wip/783

  24. added
    help wanted
    on Mar 23, 2023
  25. andreasabel commented on Mar 23, 2023

    @andreasabel
    Member
  26. added this to the 2.3.8 milestone on May 1, 2023
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

    help wantedplatform: windowsre: ghcup

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions