Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup Bash 4 and other GNU tools in MacOS based Github Action runners?

I have several bash scripts in my project that require Bash 4, GNU sed and thelike. Setting that up on local machines is quite straightforward (updating .bashrc, chsh and thelike) but I can't seem to get MacOS based Github Actions to do the same thing.

like image 956
markusthoemmes Avatar asked Jan 31 '26 07:01

markusthoemmes


1 Answers

The following Github Action YAML snipped will install brew, a newer bash version, GNU sed and put them all in the path so that the following scripts will correctly pick them up:

- name: Install Bash 4 and GNU sed on Mac
  run: |
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    brew update

    brew install bash
    brew install gnu-sed

    echo "/usr/local/bin" >> $GITHUB_PATH
    echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH

Make sure that all scripts have #!/usr/bin/env bash as their shebang as well.

like image 128
markusthoemmes Avatar answered Feb 03 '26 00:02

markusthoemmes