[GH-ISSUE #269] "sudo: command not found" in micro image #187

Closed
opened 2026-03-01 21:41:02 +03:00 by kerem · 20 comments
Owner

Originally created by @Pomax on GitHub (Jun 7, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/269

Why is the ubuntu-latest container claiming that sudo doesn't exist? It kind of has to in order to run installers.

slname: CI-CD

on:
  push:
    branches:
      - master

jobs:
  tex:
    name: Installing TeX Live and ((Xe)La)TeX related packages
    runs-on: ubuntu-latest
    shell: bash
    steps:
      - name: Installing TeX Live
        run: |
          sudo apt-get update

This crashes, even though it never should:

[ci.yml/Installing TeX Live and ((Xe)La)TeX related packages] �🚀  Start image=node:12.6-buster-slim
[ci.yml/Installing TeX Live and ((Xe)La)TeX related packages]   �🐳  docker run image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[ci.yml/Installing TeX Live and ((Xe)La)TeX related packages] ⭐  Run Installing TeX Live
| /github/workflow/0: line 2: sudo: command not found
[ci.yml/Installing TeX Live and ((Xe)La)TeX related packages]   ❌  Failure - Installing TeX Live
Error: exit with `FAILURE`: 127
Originally created by @Pomax on GitHub (Jun 7, 2020). Original GitHub issue: https://github.com/nektos/act/issues/269 Why is the `ubuntu-latest` container claiming that `sudo` doesn't exist? It kind of _has to_ in order to run installers. ``` slname: CI-CD on: push: branches: - master jobs: tex: name: Installing TeX Live and ((Xe)La)TeX related packages runs-on: ubuntu-latest shell: bash steps: - name: Installing TeX Live run: | sudo apt-get update ``` This crashes, even though it _never_ should: ``` [ci.yml/Installing TeX Live and ((Xe)La)TeX related packages] �🚀 Start image=node:12.6-buster-slim [ci.yml/Installing TeX Live and ((Xe)La)TeX related packages] �🐳 docker run image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[] [ci.yml/Installing TeX Live and ((Xe)La)TeX related packages] ⭐ Run Installing TeX Live | /github/workflow/0: line 2: sudo: command not found [ci.yml/Installing TeX Live and ((Xe)La)TeX related packages] ❌ Failure - Installing TeX Live Error: exit with `FAILURE`: 127 ```
kerem 2026-03-01 21:41:02 +03:00
Author
Owner

@Senui commented on GitHub (Jun 9, 2020):

+1; installing the sudo package is also not required on the actual Github Actions. I currently work around this by doing apt update && apt install sudo prior to my regular workflow, just for act to run without this initial failure.

<!-- gh-comment-id:641249098 --> @Senui commented on GitHub (Jun 9, 2020): +1; installing the `sudo` package is also not required on the actual Github Actions. I currently work around this by doing `apt update && apt install sudo` prior to my regular workflow, just for act to run without this initial failure.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 9, 2020):

Issue is stale and will be closed in 7 days unless there is new activity

<!-- gh-comment-id:670988029 --> @github-actions[bot] commented on GitHub (Aug 9, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Author
Owner

@przemub commented on GitHub (Oct 15, 2020):

The issue is still prevalent and prohibits running many actions.

<!-- gh-comment-id:708869374 --> @przemub commented on GitHub (Oct 15, 2020): The issue is still prevalent and prohibits running many actions.
Author
Owner

@andrewnitu commented on GitHub (Oct 21, 2020):

@Senui where do you insert this line?

<!-- gh-comment-id:713290970 --> @andrewnitu commented on GitHub (Oct 21, 2020): @Senui where do you insert this line?
Author
Owner

@Senui commented on GitHub (Oct 21, 2020):

@Senui where do you insert this line?

I just add it as the first step:

jobs:
  tex:
    name: Installing TeX Live and ((Xe)La)TeX related packages
    runs-on: ubuntu-latest
    shell: bash
    steps:
      - name: Install sudo package
        run: apt update && apt install sudo
      - name: Installing TeX Live
        run: |
          sudo apt-get update
<!-- gh-comment-id:713635399 --> @Senui commented on GitHub (Oct 21, 2020): > @Senui where do you insert this line? I just add it as the first step: ``` jobs: tex: name: Installing TeX Live and ((Xe)La)TeX related packages runs-on: ubuntu-latest shell: bash steps: - name: Install sudo package run: apt update && apt install sudo - name: Installing TeX Live run: | sudo apt-get update ```
Author
Owner

@andrewnitu commented on GitHub (Oct 21, 2020):

@Senui where do you insert this line?

I just add it as the first step:

Ah gotcha, i guess installing it again (from the perspective of the actual GitHub actions running on the web) won't cause any harm. Thanks! :)

<!-- gh-comment-id:713697601 --> @andrewnitu commented on GitHub (Oct 21, 2020): > > @Senui where do you insert this line? > > I just add it as the first step: Ah gotcha, i guess installing it again (from the perspective of the actual GitHub actions running on the web) won't cause any harm. Thanks! :)
Author
Owner

@cameron-martin commented on GitHub (Oct 22, 2020):

I'm having this problem too. Can it be reopened? @nektos

<!-- gh-comment-id:714451893 --> @cameron-martin commented on GitHub (Oct 22, 2020): I'm having this problem too. Can it be reopened? @nektos
Author
Owner

@fabrice102 commented on GitHub (Dec 31, 2020):

One solution is to use the alternative image.
See https://github.com/nektos/act#alternative-runner-images

For the sake of completeness, here is the text from the README:

If you need an environment that works just like the corresponding GitHub runner then consider using an image provided by nektos/act-environments:

⚠️ 🐘 *** WARNING - this image is >18GB 😱***

<!-- gh-comment-id:753022323 --> @fabrice102 commented on GitHub (Dec 31, 2020): One solution is to use the alternative image. See https://github.com/nektos/act#alternative-runner-images For the sake of completeness, here is the text from the README: > If you need an environment that works just like the corresponding GitHub runner then consider using an image provided by [nektos/act-environments](https://github.com/nektos/act-environments): > > - [nektos/act-environments-ubuntu:18.04](https://hub.docker.com/r/nektos/act-environments-ubuntu/tags) - built from the Packer file GitHub uses in [actions/virtual-environments](https://github.com/actions/runner). > > :warning: :elephant: `*** WARNING - this image is >18GB 😱***`
Author
Owner

@Pomax commented on GitHub (Dec 31, 2020):

given that the main problem is that sudo is no preinstalled, which takes up near as makes no difference literally no space at all, I'd much rather see sudo added to the base package. Anything else, we can install ourselves, but either the image has "root perms for everything" so that no su permissions are needed, or it comes with the few kb worth of sudo preinstalled so that things just work. Heck, even on a full perms image, sudo should exist and just do nothing special. It's not an optional command, too much relies on it merely existing =)

<!-- gh-comment-id:753220402 --> @Pomax commented on GitHub (Dec 31, 2020): given that the main problem is that `sudo` is no preinstalled, which takes up near as makes no difference literally no space at all, I'd much rather see `sudo` added to the base package. Anything else, we can install ourselves, but either the image has "root perms for everything" so that no su permissions are needed, or it comes with the few kb worth of sudo preinstalled so that things just work. Heck, even on a full perms image, `sudo` should exist and just do nothing special. It's not an optional command, too much relies on it merely existing =)
Author
Owner

@rokcarl commented on GitHub (Apr 13, 2021):

Using the apt update && apt install sudo workaround doesn't seem to work anymore:

Run apt update && apt install sudo
  apt update && apt install sudo
  shell: sh -e {0}

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
Error: Process completed with exit code 100.

<!-- gh-comment-id:818590523 --> @rokcarl commented on GitHub (Apr 13, 2021): Using the `apt update && apt install sudo` workaround doesn't seem to work anymore: ```bash Run apt update && apt install sudo apt update && apt install sudo shell: sh -e {0} WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Reading package lists... E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied) Error: Process completed with exit code 100. ```
Author
Owner

@catthehacker commented on GitHub (Apr 13, 2021):

@rokcarl what image are you using?

<!-- gh-comment-id:818596125 --> @catthehacker commented on GitHub (Apr 13, 2021): @rokcarl what image are you using?
Author
Owner

@rokcarl commented on GitHub (Apr 13, 2021):

I'm runs-on: ubuntu-latest, but now I'm thinking that I'm also using container:, so I guess this problem is within my custom docker container.

<!-- gh-comment-id:818597547 --> @rokcarl commented on GitHub (Apr 13, 2021): I'm `runs-on: ubuntu-latest`, but now I'm thinking that I'm also using `container:`, so I guess this problem is within my custom docker container.
Author
Owner

@catthehacker commented on GitHub (Apr 13, 2021):

ubuntu-latest is platform name, not image.
Image is listed in the log

[some workflow] 🚀  Start image=node:12.6-buster-slim
[some workflow] 🐳  docker run image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
<!-- gh-comment-id:818607941 --> @catthehacker commented on GitHub (Apr 13, 2021): `ubuntu-latest` is platform name, not image. Image is listed in the log ``` [some workflow] 🚀 Start image=node:12.6-buster-slim [some workflow] 🐳 docker run image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[] ```
Author
Owner

@drschwabe commented on GitHub (Jul 7, 2021):

Using the apt update && apt install sudo workaround doesn't seem to work anymore:

Run apt update && apt install sudo
  apt update && apt install sudo
  shell: sh -e {0}

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
Error: Process completed with exit code 100.

Just reviving this a little since I also came across the issue today. And found that the updated workaround can be to just use conditional ie- if running act locally vs Github Actions cloud.

   - run: chmod +x /usr/local/bin/docker-compose
     name: do something without sudo (act only)
     if: env.ACT=='true'

   - run: sudo chmod +x /usr/local/bin/docker-compose
     name: do something with sudo (Github Actions) 
     if: env.ACT!='true'  

Note you may still need to install sudo package for Github Actions.

<!-- gh-comment-id:875976242 --> @drschwabe commented on GitHub (Jul 7, 2021): > Using the `apt update && apt install sudo` workaround doesn't seem to work anymore: > > ```shell > Run apt update && apt install sudo > apt update && apt install sudo > shell: sh -e {0} > > WARNING: apt does not have a stable CLI interface. Use with caution in scripts. > > Reading package lists... > E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied) > Error: Process completed with exit code 100. > ``` Just reviving this a little since I also came across the issue today. And found that the updated workaround can be to just use conditional ie- if running act locally vs Github Actions cloud. ``` - run: chmod +x /usr/local/bin/docker-compose name: do something without sudo (act only) if: env.ACT=='true' - run: sudo chmod +x /usr/local/bin/docker-compose name: do something with sudo (Github Actions) if: env.ACT!='true' ``` Note you may still need to install sudo package for Github Actions.
Author
Owner

@Pomax commented on GitHub (Jul 8, 2021):

Quoting ACT's own explaination for why it exists:

Run your GitHub Actions locally! Why would you want to do this? Two reasons:

So if the workaround is "use different yaml for act vs. github", that's not a good workaround.

<!-- gh-comment-id:876610379 --> @Pomax commented on GitHub (Jul 8, 2021): Quoting ACT's own explaination for why it exists: > Run your GitHub Actions locally! Why would you want to do this? Two reasons: So if the workaround is "use _different yaml_ for act vs. github", that's not a good workaround.
Author
Owner

@catthehacker commented on GitHub (Jul 8, 2021):

node:12.6-buster-slim doesn't have sudo, bigger images do have it

<!-- gh-comment-id:876763452 --> @catthehacker commented on GitHub (Jul 8, 2021): `node:12.6-buster-slim` doesn't have `sudo`, bigger images do have it
Author
Owner

@Pomax commented on GitHub (Jul 9, 2021):

That's mostly not an issue: act can run the container when installing, itself, and run a script that installs the "missing from buster-slim" universals like sudo, before the user ever gets to play with it. It just doesn't, right now.

<!-- gh-comment-id:876884268 --> @Pomax commented on GitHub (Jul 9, 2021): That's mostly not an issue: act can run the container when installing, itself, and run a script that installs the "missing from buster-slim" universals like `sudo`, before the user ever gets to play with it. It just doesn't, right now.
Author
Owner

@catthehacker commented on GitHub (Jul 9, 2021):

We already provide images that include sudo and few other tools that are deemed most necessary for actions.

<!-- gh-comment-id:876974112 --> @catthehacker commented on GitHub (Jul 9, 2021): We already provide images that include `sudo` and few other tools that are deemed most necessary for actions.
Author
Owner

@Pomax commented on GitHub (Jul 9, 2021):

Then really this issue should be briefly reopened, and then closed with a comment that explains which (still small rather than 18GB) image should be used instead, because right now the issue is closed because of github automation, so anyone who finds it is still going to be none the wiser about a solution.

<!-- gh-comment-id:877317388 --> @Pomax commented on GitHub (Jul 9, 2021): Then really this issue should be briefly reopened, and then closed with a comment that explains which (still small rather than 18GB) image should be used instead, because right now the issue is closed because of github automation, so anyone who finds it is still going to be none the wiser about a solution.
Author
Owner

@catthehacker commented on GitHub (Jul 9, 2021):

We still have #107 open that is pinned so people should see it easily, marking it as duplicate since main discussion is in #107

<!-- gh-comment-id:877364532 --> @catthehacker commented on GitHub (Jul 9, 2021): We still have #107 open that is pinned so people should see it easily, marking it as duplicate since main discussion is in #107
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#187
No description provided.