Unable to cache ruby gems


I am trying to get my Ruby gems to cache. However it is not working.
I have tried
bundle check --path=~/programs/vendor/bundle || bundle install --path=~/programs/vendor/bundle --jobs=4 --retry=3
and I see in Save Cache

I am noticing that the .bundle is not getting saved, but my vendor/bundle is getting saved.
However when I run bundle check on that directory, it doesn’t find anything, and goes ahead and downloads and installs everything. So now I am losing time in Save and Restore cache, and I haven’t gained any speed from the bundle install command.

What am I doing wrong here? Any ideas?
I have also tried to install the vendor directory in a different location, and add that path to the cache_dependancies but without any luck.
Same thing happens, the requirements are not met, and it downloads the gems and installs them, instead of using the cache.

Thanks in advance


Huzzah! I have finally solved this problem.

I have figured out what the root of the problem is.
This is a wordpress issue, but it might pop up in other systems. The problem is we were moving things around.
With wordpress our repo is the plugins folder. Because of this, we have to move all our repo code out of the main folder, install wordpress, and then move our repo code into the plugins folder.
All this moving around caused problems in the caching.

The cache is restored into /home/ubuntu/programs/wp-content/plugins/programs-tests/gem-bundle/vendor

But because we are in wordpress, we have to install wordpress, so we copy every thing in ~/programs into ~/repo then install wordpress, and move everything in ~/repo into ~/programs/wp-content/plugins.

This means that now the cached gems are in this location, the wrong one ~/programs/wp-content/plugins/wp-content/plugins/programs-tests/gem-bundle/vendor

That is why bundle can never see the vendor file. The cached folder is restored with it’s full path wp-content/plugins/...
Then we move it out, install wordpress, and then move everything into the newly created plugins folder wp-content/plugins
So that means we just moved the old wp-content/plugins inside of the new wp-content/plugins which of course results in wp-content/plugins/wp-content/plugins

I fixed this by moving the cached file into the proper plugins folder