Cache problem

Hello

There are a lot of caches problems now.

if [ ! -d “venv” ]; then ----> I have to remove this line was working before during several months.

pip install…

Traceback (most recent call last):

File “/root/project /sync.py”, line 4, in

from google.oauth.credentials import Credentials

ModuleNotFoundError: No module named ‘google’

Hi @jvachez, that check only tells you the folder exists, not that the venv inside it still works. If the cache was restored from a fallback key, or the Python version in the image changed, you can end up with a venv that has a broken interpreter link or is missing packages, so pip install gets skipped and the import fails.

I’d tie the cache key to both the requirements file and the Python version, and always run pip install (it’s quick when everything is already installed):

- run: python --version > .pyver
- restore_cache:
  keys:
    - venv-v2-{{ arch }}-{{ checksum ".pyver" }}-{{ checksum "requirements.txt" }}
- run: |
    python -m venv venv
    . venv/bin/activate
    pip install -r requirements.txt
- save_cache:
  key: venv-v2-{{ arch }}-{{ checksum ".pyver" }}-{{ checksum "requirements.txt" }}
  paths:
    - venv

Changing the v2 prefix is also an easy way to force a fresh cache when needed. Did your image tag change around when this started?