Ruby bundle can't find gem installed by itself

Here is part of the build log for rails application:
I installed net-http-pipeline gem via bundler and evenr pure gem…

$ bundle install --jobs=3
<...>
Using net-http-pipeline 1.0.1
<...>

$ gem list|grep http
net-http-persistent (2.9.4)
net-http-pipeline (1.0.1)

$ gem install net-http-pipeline
Successfully installed net-http-pipeline-1.0.1
1 gem installed
0.36s

But then bundle can’t find the gem and stops processing…

$ bundle show net-http-pipeline
Could not find net-http-pipeline-1.0.1 in any of the sources

The command "bundle show net-http-pipeline" failed and exited with 7 during .

How it can be?

Full log is here:
https://travis-ci.org/znamenica/dneslov/builds/617127079?utm_medium=notification

You probably got confused about what gem install vs bundle install do. I see lots of redundant installations in your log.

gem install install gems globally for the active Ruby installaiton. bundle install install them into a private stash not accessible to globally-installed code, you are supposed to use bundle exec to run code that should have access to them (this way, bundle wraps your command and adds the private stash location to Ruby’s gem search path before invoking the command – the documentation calls this “run in bundler’s context”). This private stash is also specific to the current directory: you need to be in the directory where your Gemfile is for bundle to pick the correct one.

See e.g. https://andre.arko.net/2015/04/28/how-does-bundler-work-anyway/ if you need more explanation.

You probably got confused about what gem install vs bundle install do. I see lots of redundant installations in your log.

Yes, I now the difference between them, even in my local getup the gem, which will install the specified gem into bundle space, but anyway, which approach I try installed the gem “net-http-pipeline” by, it still isn’t found in the bundler env, however I see it in Gemlock log, and Gemfile.lock file. So problem is not where you’ve noted in…

Then troubleshoot the situation properly. Randomly running commands in the hope that the problem will go away will only get you so far.

Check where bundler installs stuff, the contents of that location and how that corresponds to bundle show, whether Ruby run in bundler context includes that module in its search path, whether it loads if you specify its path explicitly. Get more information from Bundler to understand what it’s doing and what it’s seeing.

E.g. running bundle install --verbose immediately told me:

Found changes from the lockfile, re-resolving dependencies because you added a new platform to your gemfile

which means that you Gemfile.lock is being ignored. (But I’m running Windows so for Travis environment, this may not be the case.)

Imprint