Skip to content

Unavoidable use of sudo on osx & linux runners #57

@dekimsey

Description

@dekimsey

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
Image

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions