-
Notifications
You must be signed in to change notification settings - Fork 12
Unavoidable use of sudo on osx & linux runners #57
Description
Summary
The action appears to always require the use sudo. On self-hosted runners that prohibits the use of sudo, this prevents the action from running.
Neither the defaults, or attempting to set specific paths will work. The error message is the same.
- name: Setup Bats and bats libs
id: setup-bats
uses: bats-core/bats-action@42fcc8700f773c075a16a90eb11674c0318ad507 # 3.0.1
# Note: manually setting these paths has no effect, sudo is still required
# with:
# support-path: ${{ github.workspace }}/bats/bats-support
# assert-path: ${{ github.workspace }}/bats/bats-assert
# detik-install: false
# file-install: false
sudo detection
I've looked into the code around how the base directory is being computed and how sudo is chosen, but I don't understand the intent. Looking at the set-paths step specifically, I cannot determine how it can ever not require sudo unless HOME is /.
DEFAULT_BASE_DIR="/usr/lib"
[[ "${DEFAULT_BASE_DIR}" == "$HOME"* ]] && CMD="" || CMD="sudo"
There doesn't seem to be any way to prevent this as the variable is set to a hard-coded value and then immediately checked.
[suggestion] Cache downloads, not install
It's possible that caching the download into the runner's tool cache directory instead via actions/github-script and @actions/tool-cache would allow the action to get all the benefits of caching without issues trying to use caching & sudo. Re-installing from the cached tool would be rather cheap and could reduce the complexity of the overall action.
Thank you!