actions / actions/actions-runner-controller

Can not create python virtual environment because python3-venv package is not installed

Open
#965 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
6.5k
Forks
1.5k
Avg merge
2d 2h
Merged PRs (30d)
27

Description

Describe the bug

One difference with the GitHub ubuntu-latest runner (https://github.com/actions/virtual-environments/blob/2d46e3f4d965927ce242d1fed6d5e92c7ff076c5/images/linux/scripts/installers/python.sh#L17) is the presence of the python3-venv package.

This doesn't matter if you're just using the setup-python action for your own code, but it does when you're running another action (e.g. https://github.com/akaihola/darker/blob/master/action.yml) that tries to use a Python virtual environment to isolate itself from your code, then you hit the kind of brick wall explained in https://github.com/pypa/build/issues/224:

The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt install python3.8-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/runner/_work/_actions/akaihola/darker/github-action-v1.3.2-1/.darker-env/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

Traceback (most recent call last):
  File "/runner/_work/_actions/akaihola/darker/github-action-v1.3.2-1/action/main.py", line 14, in <module>
    run([sys.executable, "-m", "venv", str(ENV_PATH)], check=True)
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'venv', '/runner/_work/_actions/akaihola/darker/github-action-v1.3.2-1/.darker-env']' returned non-zero exit status 1.

This is also reproducible by doing: docker run -it summerwind/actions-runner:latest python -m venv /tmp/boom or the same in a base Debian/Ubuntu setup.

Checks

  • My actions-runner-controller version (v0.x.y) does support the feature
  • I'm using an unreleased version of the controller I built from HEAD of the default branch

To Reproduce
Steps to reproduce the behavior:

Call python -m venv /tmp/path-to-venv inside a summerwind/actions-runner image.

Expected behavior

Python virtual env creation should work.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Controller Version [e.g. 0.20.2]
  • Deployment Method [e.g. Helm and Kustomize ]
  • Helm Chart Version [e.g. 0.11.0, if applicable]

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the actions-runner image definition and reproduce python -m venv /tmp/path-to-venv in the summerwind/actions-runner image. Identify where its Python packages are installed; done means virtual environment creation succeeds without the ensurepip or python3-venv error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.