Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"sudo: command not found" in micro image #269

Closed
Pomax opened this issue Jun 7, 2020 · 20 comments
Closed

"sudo: command not found" in micro image #269

Pomax opened this issue Jun 7, 2020 · 20 comments
Labels
area/runner Relating to errors in the runner meta/duplicate This issue or pull request already exists

Comments

@Pomax
Copy link

Pomax commented Jun 7, 2020

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
@Senui
Copy link

Senui commented 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.

@cplee cplee added area/runner Relating to errors in the runner meta/workaround A workaround has been identified. labels Jun 9, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2020

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

@przemub
Copy link

przemub commented Oct 15, 2020

The issue is still prevalent and prohibits running many actions.

@andrewnitu
Copy link

@Senui where do you insert this line?

@Senui
Copy link

Senui commented 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

@andrewnitu
Copy link

@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! :)

@cameron-martin
Copy link

cameron-martin commented Oct 22, 2020

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

@fabrice102
Copy link

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 😱***

@Pomax
Copy link
Author

Pomax commented 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 =)

@rokcarl
Copy link

rokcarl commented 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.

@catthehacker
Copy link
Member

@rokcarl what image are you using?

@rokcarl
Copy link

rokcarl commented 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.

@catthehacker
Copy link
Member

catthehacker commented 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=[]

@drschwabe
Copy link

drschwabe commented 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.

@Pomax
Copy link
Author

Pomax commented 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.

@catthehacker
Copy link
Member

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

@Pomax
Copy link
Author

Pomax commented 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.

@catthehacker
Copy link
Member

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

@Pomax
Copy link
Author

Pomax commented 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.

@catthehacker catthehacker added meta/duplicate This issue or pull request already exists and removed meta/workaround A workaround has been identified. stale labels Jul 9, 2021
@catthehacker
Copy link
Member

catthehacker commented 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

@catthehacker catthehacker changed the title "sudo: command not found" should never be possible "sudo: command not found" in micro image Jul 9, 2021
wiktor-k added a commit to wiktor-k/org-test that referenced this issue Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runner Relating to errors in the runner meta/duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

10 participants