Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sudo apt install in github action

In one of the project I work on, I use graphviz for visualization and have test code for this functionality.

But to test the code graphviz must be installed. I setup CI as the github action. But I couldn't manage to install graphviz as the github action.

We have the following yml

name: test
on: push
  
jobs:
  test_coverage:
    name: Test Software
    runs-on: ubuntu-latest
    steps:
      # See: https://github.com/actions/checkout
      - uses: actions/checkout@v3
      - name: Setup Graphviz
        run: |
          sudo apt-get -y install graphviz

But it fails with

sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper

I am using Github Enterprise, if this means anything. How can I fix such an issue? Thanks.

like image 209
dragon_and_dracula Avatar asked Oct 17 '25 13:10

dragon_and_dracula


1 Answers

Check first which users is executing that command:

run: |
  id -a
  sudo apt-get -y install graphviz

Said user is probably not added to the sudoers.
Yet, the GitHub Actions documentation mentions:

The Linux and macOS virtual machines both run using passwordless sudo. When you need to execute commands or install tools that require more privileges than the current user, you can use sudo without needing to provide a password.
For more information, see the "Sudo Manual."

Check if this works better with:

runs-on: ubuntu-20.04
# or
runs-on: ubuntu-22.04

For the OP dragon-and-dracula, in the comments:

I ended up using my own container that got the graphviz preinstalled.
I think the main reason for the error was because something about GitHub Enterprise.

like image 86
VonC Avatar answered Oct 22 '25 06:10

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!