When restoring cached Rubygems from a previous build, my VM is always reinstalling & rebuilding gems that have native extensions, even when they were restored from the cache. I am running a macOS VM with Xcode 10.2, Ruby 2.5.3p105, and Bundler 1.17.3.
Here is my cache restore step:
- restore_cache:
key: 1-gems-{{ checksum "Gemfile.lock" }}
Here is how I install gems:
bundle check --path vendor/bundle || bundle install --path vendor/bundle
And here is my cache save step:
- save_cache:
key: 1-gems-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
When I run, here are the relevant logs:
The following gems are missing
* unf_ext (0.0.7.5)
* json (2.2.0)
* sqlite3 (1.4.0)
Install missing gems with `bundle install`
Ignoring json-2.2.0 because its extensions are not built. Try: gem pristine json --version 2.2.0
Ignoring sqlite3-1.4.0 because its extensions are not built. Try: gem pristine sqlite3 --version 1.4.0
Ignoring unf_ext-0.0.7.5 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.7.5
bundle install
then runs and succeeds, rebuilding the gems that have native extensions.
It seems that these three gems must have components outside of vendor/bundle
but I don’t know what those would be.
Anyone have an idea what’s happening and how to fix it?