Gitlab can't clean my cache on building. How to fix this problem?
Executor: shell
Fetching changes...
warning: failed to remove config/__pycache__/__init__.cpython-36.pyc
warning: failed to remove config/settings/__pycache__/local.cpython-36.pyc
warning: failed to remove config/settings/__pycache__/__init__.cpython-36.pyc
warning: failed to remove config/settings/__pycache__/common.cpython-36.pyc
warning: failed to remove config/settings/__pycache__/test.cpython-36.pyc
warning: failed to remove docs/__pycache__/__init__.cpython-36.pyc
all tiers. self-managed. By default, GitLab caches application settings for 60 seconds.
A cache is one or more files that a job downloads and saves. Subsequent jobs that use the same cache don't have to download the files again, so they execute more quickly. To learn how to define the cache in your . gitlab-ci. yml file, see the cache reference.
These are scripts that you choose to be run before the job is executed or after the job is executed. These can also be defined at the top level of the YAML file (where jobs are defined) and they'll apply to all jobs in the . gitlab-ci. yml file.
Luckily I was having the exact same issue as you (I think).
A little background:
I was using gitlab ci to build using a remote runner (shell) that would build a docker image and then run some tests.
Cause:
I was mounting a local directory inside the container by passing the -v flag to
docker run
(there are other ways to do this with compose yml for example).Because the docker container runs as root the generated __pycache__ directories and files are owned by root on the local filesystem; This means that docker-runner does not have permission to delete them on the next build.
The solution:
Remove the mount and copy the files instead.
I workaround by not let python create *.pyc
files
https://docs.python.org/3/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With