Skip to content

Script falls back to use sh if bash is not available

Problem

The script step fails to run when bash is not available in the operating system.

More details

The script step only knows how to run scripts with bash. Even when running scripts with bash there is some subtly to making it work everywhere. Sometimes it's located in /usr/bin/bash, sometimes /usr/local/bin/bash. When the current GitLab Runner "compiles" a script for the "bash" shell, it falls back on using sh when bash isn't available. This allows users "bootstrap". For example the runner-incept Kubernetes test job uses a container with only sh. So it installs bash at the beginning of the job. That doesn't work in steps because there is no way to run a script without bash! (yet)

Proposal

Provide a similar series of fallbacks in order to be compatible with GitLab Runner. The fallback will be in this order:

  1. /usr/local/bin/bash
  2. /usr/bin/bash
  3. /bin/bash
  4. /usr/local/bin/sh
  5. /usr/bin/sh
  6. /bin/sh
  7. /busybox/sh

(source)

Out of scope

The proposed solution does not work for Powershell/Windows.

Related

Recommendation from #85 (comment 2007760819)

Edited by Cameron Swords