Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default shell to bash #103

Open
riker09 opened this issue Jul 12, 2021 · 2 comments
Open

Change default shell to bash #103

riker09 opened this issue Jul 12, 2021 · 2 comments

Comments

@riker09
Copy link
Contributor

riker09 commented Jul 12, 2021

My GitHub workflows broke over the weekend. A quick investigation showed that you updated your base image recently.

This is my GitHub action;

      - name: Deploy to Firebase
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only hosting:myapp --message \"${COMMIT_MESSAGE:0:200}\"
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
          PROJECT_ID: ${{ env.PROJECT_ID }}

and it results in this error: sh: 1: Bad substitution.

Yes, I know, relying on @master is a terrible idea and in fact the reason why my workflows went south. However, I would greatly appreciate it if you could change the default shell of the buster image back to bash so I could use \"${COMMIT_MESSAGE:0:200}\".

@w9jds
Copy link
Owner

w9jds commented Jul 12, 2021

This hasn't changed, it has used sh since the initial implementation. The issue was probably that it was pretty busted for about a day so you are right doing @master is a bad idea. The main reason for switching off alpine was mostly caused by issues with missing c libraries used by some things in functions.

@aravindvnair99
Copy link
Contributor

@riker09 I hadn't changed the default shell. It is sh itself as @w9jds mentioned. But I just noticed something:

On alpine

$ which sh
/bin/sh
$ readlink -f $(which sh)
/bin/busybox
$ which bash
The command '/bin/sh -c which bash' returned a non-zero code: 1
$ readlink -f $(which bash)
BusyBox v1.31.1 () multi-call binary.

Usage: readlink [-fnv] FILE

Display the value of a symlink

        -f      Canonicalize by following all symlinks
        -n      Don't add newline
        -v      Verbose
The command '/bin/sh -c readlink -f $(which bash)' returned a non-zero code: 1

On buster

$ which sh
/bin/sh
$ readlink -f $(which sh)
/bin/dash
$ which bash
/bin/bash
$ readlink -f $(which bash)
/bin/bash

TLDR

  • buster has both sh and bash unlike alpine which only has sh
  • alpine uses busybox whereas buster uses dash
  • sh is the default, but both are symlinked to two different things

Using master

And as for using the master branch, builds which failed such as my PRs #99 and #100 were not pushed to Docker Hub. But yes, master isn't recommended for any GitHub Actions unless you want to live on the "bleeding edge" as releases are not released often especially in this repository.

Why buster instead of alpine?

alpine lacks many tools/software/bundles which are required for various npm dependencies when using Google Cloud Functions. But they are present in buster. For example, TensorFlow which is widely used won't compile on alpine (#98). And although alpine is slightly bigger (1.6 times at the moment) than buster, GitHub Actions VMs are hooked up to high-speed internet and hence pulling images won't take time either. I only noticed a difference of 1 - 2.5 seconds in my test. (Stating this as users were concerned about time to deploy)

Issue

The difference is in Debian dash (Debian Almquist shell) vs Busybox ash (Almquist shell). The substring parameter expansion is not part of the POSIX shell specification. Hence you can't do that in dash.

Solution

I'm unsure at the moment although I do see this: https://stackoverflow.com/questions/47332006/substring-in-sh-returns-bad-substitution. Will follow up if I have any suggestions or workarounds.

@w9jds w9jds closed this as completed Nov 16, 2022
@w9jds w9jds reopened this Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants