How to install packages on runner

I wanted to install a standard Linux package that I would then use as part of a shell script. I got an interesting answer. Apparently we don’t have permissions to install packages on the workflow’s runner. That makes sense, but I still need the basic ping capability to run from a shell script. How should this be done? I’ve done something similar with other libraries, but those may be specialized.

This is the command and the errors I got.
Run apt-get install -y iputils-ping
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

This is a snippet of another workflow that did work to install python.
run: |
python -m pip install --upgrade pip
pip install pytest

It looks like iputils-ping is included by default on all of the Ubuntu images at least, and you can check to see what software is installed by default on GitHub-hosted runners. So unless there’s something else you need, you should be good to go?

1 Like

According to the documentation on virtual environments the hosted runners allow passwordless sudo, which should let you install packages.

Another option would be to run your jobs in Docker containers where you are root by default.