Closed kaylangan closed 4 years ago
@andreasdotorg
Git's bash shell has been the default on Win images, so MSYS2 is not included in Path. Pacman is located at C:\msys64\usr\bin
. You may need to add other locations to Path to use the MSYS2 MinGW tools.
In appveyor, I used
$path = ([System.Environment]::GetEnvironmentVariable('PATH', 'Machine').Split(';') | Where-Object { $_ -notmatch 'Git' }) -join ';'
[System.Environment]::SetEnvironmentVariable('PATH', $path, 'Machine')
to remove git from the path so I could use msys2's C:\msys64\usr\bin;C:\msys64\mingw64\bin
in the path without any conflicts, you might be able to modify it to match github actions better
I'm using the following to run commands in MSYS/MinGW32 or MSYS/MinGW64 bash shell:
name: Test Windows
on: [push, pull_request]
jobs:
msys:
runs-on: windows-2019
strategy:
matrix:
mingw: ["MINGW32", "MINGW64"]
include:
- mingw: "MINGW32"
package: "mingw-w64-i686"
- mingw: "MINGW64"
package: "mingw-w64-x86_64"
defaults:
run:
shell: bash.exe --login -eo pipefail "{0}"
env:
MSYSTEM: ${{ matrix.mingw }}
CHERE_INVOKING: 1
name: MSYS2 ${{ matrix.mingw }}
steps:
- name: Set up shell
run: echo ::add-path::C:\msys64\usr\bin\
shell: pwsh
- name: Print system version
run: |
uname
- name: Install package
run: |
# install python
pacman -S --noconfirm ${{ matrix.package }}-python3-setuptools
# build the project
python3 setup.py install
The first step adds msys at the start of the path, and the MSYSTEM
and CHERE_INVOKING
envvars tell MSYS bash to run on the given platform (MinGW32 or MinGW64) and in the project directory. I'm setting a default custom shell to run multiple steps in the MSYS shell, but you can explicitly set it for each step.
Edit: added @1480c1's suggestion
You might want to add -eo pipefail
to your shell:
line to emulate what github actions uses for their bash
@nulano, I updated the README in eine/setup-msys2 to show how to set a default shell, as you did. The main differences between your approach and setup-msys2 are the following:
CHERE_INVOKING: 1
is the default in setup-msys2: bash.exe --norc -ilceo pipefail "cd $OLDPWD && %args%"
.git
from the host and the one in MSYS2.You can find multiple workflow setups in https://github.com/eine/setup-msys2/blob/master/.github/workflows/action.yml.
Ref #916 #908 #906 #899 #355 #342
Msys2 was added to Windows images, this issue is closed.
Tool information
Virtual environments affected
Can this tool be installed during the build? Yes, via
choco install msys2
.Are you willing to submit a PR?