actions / setup-haskell

Set up your GitHub Actions workflow with a specific version of Haskell (GHC and Cabal)
MIT License
71 stars 30 forks source link

How to install system libraries on windows? #37

Open hasufell opened 4 years ago

hasufell commented 4 years ago

I think it's common to have to install system libraries. I don't see any description on how to do that with this action (for both stack and cabal).

hasufell commented 4 years ago

For cabal, I tried

    - name: Install system dependencies (windows)
      if: matrix.os == 'windows-latest'
      run: mingw64-pkg install zlib

It failed with


Run mingw64-pkg install zlib
Bash environment variable found, are you sure you installed cabal and msys2 via chocolatey?
At C:\ProgramData\chocolatey\lib\cabal.3.2.0.0\tools\mingw64-pkg.ps1:39 char:3
+   throw ("Bash environment variable found, are you sure you installed ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Bash environmen...via chocolatey?:String) [], RuntimeException
    + FullyQualifiedErrorId : Bash environment variable found, are you sure you installed cabal and msys2 via chocolat 
   ey?

Error: Process completed with exit code 1.

https://github.com/hasufell/stack2cabal/runs/1172870260?check_suite_focus=true#step:7:1

hazelweakly commented 4 years ago

This took way too long to figure out, but I think I have a minimal example here:

jobs:
  zlib:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - uses: msys2/setup-msys2@v2
        with:
          update: true
          install: zlib
      - uses: haskell-CI/setup@main
        with:
          ghc-version: 8.8.4
          cabal-version: 3.2.0.0
      - run: cabal update
      - run: cabal run

(with a minimal hello-world of importing the zlib library to make sure I'm using something that needs zlib)

I couldn't get mingw64-pkg working regardless of whether or not I installed msys2 via chocolatey or the action. This is the codepath that is causing it to fail. I'm not quite sure why it's there; although it seems to just be a wrapper around pacman -S $package_name, which would make its functionality equivalent to the setup-msys2 snippet above.

expipiplus1 commented 4 years ago

There's nothing Haskell specific about installing system packages.

Cabal or stack just has to be informed about their include/lib locations, and DLL locations added to PATH.

I've been using pkgconfiglite installed by chocolatey for some packages: https://github.com/expipiplus1/vulkan/blob/master/.github/workflows/ci.yml#L63 (in this action I install some dependencies for Cabal and Stack (near the end))