Cache: Caching on macOS dependent on runner version number in workspace path

Created on 4 May 2020  路  5Comments  路  Source: actions/cache

Not fully sure if this belongs in this repo or the runner repo (https://github.com/actions/runner) - however when using the GH-hosted macOS runner, the workspace directory includes the runner version number in the path, e.g.

linux - "/home/runner/work/repo-name"
Windows - "d:\\a\\repo-name"
macOS - "/Users/runner/runners/2.169.1/work/repo-name"

This breaks all caches that include files with absolute paths in them as the runner is updated, for instance any Python executable installed and cached will have entrypoint stub scripts that point to the interpreter with an absolute shebang - however this will break as the runner version is updated, e.g.

#!/Users/runner/runners/2.169.0/work/repo-name/.venv/bin/python
# -*- coding: utf-8 -*-
import re
import sys

from pip._internal import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

For now I'm extracting the runner version number from the path on macOS and adding as a cache parameter, but this is unexpected behaviour.

Most helpful comment

This has also been discussed at https://github.com/actions/virtual-environments/issues/713 where I mentioned this being an issue with SwiftPM.

I'm seeing the path is now /Users/runner/work/{repo}/ so I think this solved the problem.

I'm mainly commenting to link the 2 issues but also to say thank you :)

All 5 comments

for now the following works around this issue, assuming you have python in your env, however adding the version to the runner context would work just as well to aid caching

- name: set runner version
  run: echo "::set-env name=RUNNER_VERSION::$(python3 -c 'import os;import sys;print(os.getcwd().split("/")[4] if sys.platform == "darwin" else "unused")')"

Thank you for investigating this issue, and posting this workaround, @mands - it saved me a bunch of time this morning!

Hello, @mands
We have updated a provisioner to use the new /Users/runner/work path. Could you please check from your side?

This has also been discussed at https://github.com/actions/virtual-environments/issues/713 where I mentioned this being an issue with SwiftPM.

I'm seeing the path is now /Users/runner/work/{repo}/ so I think this solved the problem.

I'm mainly commenting to link the 2 issues but also to say thank you :)

Just got around to updating my own actions workflows and can confirm all now works as expected - thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gladhorn picture gladhorn  路  4Comments

jwt27 picture jwt27  路  3Comments

Fatme picture Fatme  路  3Comments

dhadka picture dhadka  路  5Comments

hugovk picture hugovk  路  6Comments