Article 4SD1V Using “git bash” from AppVeyor

Using “git bash” from AppVeyor

by
jonskeet
from Jon Skeet's coding blog on (#4SD1V)

Update: I don't know whether it was partially due to this blog post or not, but AppVeyor has fixed things so that you don't (currently, 20th October 2019) need to use the fix in this post. You may want to include it anyway, for the sake of future-proofing.

TL;DR: If your AppVeyor build starts breaking because it's started using WSL bash, change the path in your YAML file - see the end of the post for an example.

For years now, I've used bash scripts for all kinds of automation in Windows projects. The version of bash I use is the one that comes with Git for Windows - I believe its origins include Cygwin, MSYS2, and MinGW-w64. (I don't know enough about the differences between those projects or which builds on which to say more. Fortunately, I don't need to.) This version of bash is installed by default AppVeyor, the CI system I typically use for Windows builds, so I don't need to do anything else.

Importantly, I don't want to use Windows Subsystem for Linux (WSL) on Windows builds. The point of doing the build is to use the Windows tool chains. I use Travis for doing Linux builds.

On October 11th 2019, my Noda Time AppVeyor build failed with this error:

build/appveyor.sh: line 11: dotnet: command not found

It turns out this is because AppVeyor has started shipping WSL with its Visual Studio 2019 images. The bash from WSL is earlier in the path than the version of bash from git, so that one is used, and everything starts failing.

It took a little while to diagnose this, but the fix is pretty easy - you just need to put git bash earlier in your path. I chose to do this in the "install" part of appveyor.yml:

install: # Make sure we get the bash that comes with git, not WSL bash - ps: $env:Path = "C:\Program Files\Git\bin;$env:Path"

Using just that change, the build started working again. Hooray!

External Content
Source RSS or Atom Feed
Feed Location http://codeblog.jonskeet.uk/feed/
Feed Title Jon Skeet's coding blog
Feed Link https://codeblog.jonskeet.uk/
Reply 0 comments