act: "sudo: command not found" in micro image

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

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 23
  • Comments: 20 (6 by maintainers)

Commits related to this issue

Most upvoted comments

The issue is still prevalent and prohibits running many actions.

+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.

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

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.

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

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

@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

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.