I have an error sometimes when running bundle install
Bundler::GemspecError: Could not read gem at /path/to/cache/gem It may be corrupted
I have a web URL filter that seems to block the initial attempt at downloading the gem (if I delete the cache file in question and run again, it works). Furthermore, the contents of the cache file is the html from the web URL filter page.
I would like to not have to delete the cache file and re-run, I would like to have bundler automatically rerun if this scenario happens.
I have thought about running bundle from a Ruby script, but I cannot seem to capture the error.
I need to automate the build of my project in Docker.
begin
puts "Starting bundle install"
system %w[bundle install]
rescue Bundler::GemspecError => e
puts e
end
However, I cannot seem to rescue the exception; the error thrown is:
Bundler::GemspecError: Could not read gem at /Users/lewis/.rvm/gems/ruby-2.3.3@hendricks-offline/cache/rack-2.0.3.gem. It may be corrupted.
An error occurred while installing rack (2.0.3), and Bundler cannot continue.
Make sure that `gem install rack -v '2.0.3'` succeeds before bundling.
The exception is not captured, as I get no output. I have been advised that this is because i am running bundle now outside of Ruby world, so to speak.
How would I go about this?