julia-actions / cache

A shortcut action to cache Julia artifacts, packages, and registries.
MIT License
38 stars 9 forks source link

Expand paths which use tilde #141

Closed omus closed 3 months ago

omus commented 3 months ago

I noticed a bug with https://github.com/julia-actions/cache/pull/140 where the registry failed to be updated:

...
626M    /home/runner/.julia/registries
20K     /home/runner/.julia/scratchspaces
1.1G    total
Run if [ -d "~/.julia/registries" ] && [ -n "$(ls -A "~/.julia/registries")" ]; then
Registries directory does not exist or is empty. Skipping registry update

The problem turned out to be that using ~ in a quoted path doesn't expand it which results in failed checks:

❯ [ -d "~/.julia/registries" ] && [ -n "$(ls -A "~/.julia/registries")" ] && echo pass

❯ [ -d "$HOME/.julia/registries" ] && [ -n "$(ls -A "$HOME/.julia/registries")" ] && echo pass
pass

Seems best we just use the expanded path to avoid these kind of mistakes from occurring again.