CircleCI-Public / CircleCI-Public/cimg-python

Bug Report: cimg/python:x.y is unusable with venv caching

Open
#250 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Dockerfile
Stars
36
Forks
33
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Caching venv si common practice [as documented](https://circleci.com/docs/caching/). However, on `cimg/python`, `python -m venv venv` produces a virtual environment with a symlink to a fixed *x.y.z* python version (`/home/circleci/.pyenv/versions/3.11.10/bin/python` for instance on `cimg/python:3.11`.

This causes `. venv/activate` to fail with `Error: [Errno 2] No such file or directory: 'venv/bin/python'` as soon as the image is updated with a new minor Python version.

**To Reproduce**
Using the following `config.yml`:

```yml
jobs:
build:
docker:
- image: cimg/python:3.11.4
steps:
- checkout
- restore_cache:
keys:
- << pipeline.parameters.cache-version >>-{{ checksum "Pipfile.lock" }}
- << pipeline.parameters.cache-version >>-
- run:
name: install dependencies
command: |
python -m venv /tmp/venv
. /tmp/venv/bin/activate
pip install pipenv
pipenv install --dev
- save_cache:
paths:
- /tmp/venv
key: << pipeline.parameters.cache-version >>-{{ checksum "Pipfile.lock" }}
```

Change the used image from `cimg/python:3.11.4` to `cimg/python:3.11` and the CI should fail with the *No such file or directory* error.

**Expected behavior**
Caching the venv should not make the CI to suddenly fail as soon as the Python minor changes when using `cimg/python:x.y`.

**Workarounds**
Use `cimg/python:x.y.z` instead of `cimg/python:x.y` wich is inconveniant.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.