hashFiles('file') fails for an existing file

Hi,

this is my first post, I hope it’s ok.

For caching I need a hash of my Gemfile.lock, which is located in the root dir of the repository. I tried:

${{ hashFiles('Gemfile.lock') }}

which does not work, though the file does exist in the directory. The reported error is:

##[error]The template is not valid. 'hashFiles(Gemfile.lock)' failed. Search pattern 'Gemfile.lock' doesn't match any file under '/home/runner/work/www.ruby-lang.org/www.ruby-lang.org'

It works when I use this pattern:

${{ hashFiles('**/Gemfile.lock') }}

In my case, there is only one Gemfile.lock in the repository, so it’s not really a problem. But strictly speaking it’s not what I wanted.

Additionally, the returned hash is not the SHA-256 sum I get with “sha256sum Gemfile.lock” on my local (Ubuntu) machine, is that to be expected?

The log of the workflow run can found here:

https://github.com/ruby/www.ruby-lang.org/commit/0cb75fafb86b1663f78e876282f5815401170795/checks?check_suite_id=303279531

Thanks,

Marcus (@stomar)

2 Likes

Getting this issue for macOS. Additionally, using **/ with hashFiles also seems to fail outright on Windows:

Search pattern '**/package-lock.json' doesn't match any file under 'd:\a\project\project'

I’m guessing the glob library isn’t normalizing directory separators.

We are aware of both of these issues and fixes are being worked on

https://github.com/actions/cache/issues/39#issuecomment-552252932

1 Like

the fix should be rolled out everywhere now

1 Like

Yes, it works now. Thank you!