Gems not in Local Gems after bundle install
Your default in this app is to install to vendor/bundle
. You can tell this by It was installed into ./vendor/bundle
text which appears after gems installation.
Bundler documentation specifies that you have to pass --system
to install in system location:
--system: Install to the system location ($BUNDLE_PATH or $GEM_HOME) even
if the bundle was previously installed somewhere else for this
application
EDIT: More explanation is that your ruby knows only about gems installed with --system option when not using bundle exec
. You can see your gems from vendor/bundle
or whatever path you've chosen by running bundle exec gem list
or (as Casper noticed) bundle list
. Now it is your choice whether you want your gems in system location or in application directory.
Single file from gem missing after bundle install, included when using gem install
So the root cause of the issue was the existence of the vendor/cache
from bundler, which included a version of the gem with some faulty namings. As the gem version was not bumped while troubleshooting the issue, bundler always used the cached version.
Even though the gem was uninstalled from the system completely, it was still available in the local vendor/cache
. Upon bundle install
in that folder, bundler realized it had that gem available and used it from the cache.
That's also why the issue didn't appear with gem install
, since with that the vendor/cache
created by bundle gets ignored.
Gem list doesn't show bundler after Successfully installed bundler
The PATH
of the root user is likely not the same as the PATH
of your current user. Therefore the gem
command that root loads will not be the same as the gem
command you load as a normal user. This makes sudo gem install
save the gems into a different location (the location of the Ruby installation found in the PATH
of the root user).
To fix this issue, the most straightforward solution is to force root to use the same gem command by giving it the full path:
sudo `which gem` install ...
Note the use of backticks. Using backticks this way, the command will essentially expand to something like:
sudo /some/path/to/the/user/ruby/installation/bin/gem install ...
To figure out if the gem
command of root is different from your default gem
command, you can do this:
# As normal user check output of this command
which gem
# ..and compare it to the output of this command
sudo which gem
bundle exec' complains about gem not being installed, even after 'bundle install'
After deleting the env
directory and reinstalling, I noticed it created subdirectories for two Ruby versions - 2.1.0 and 2.2.0. The latter was my current version of Ruby, but the directory was empty (all the gems were installed into the env/ruby/2.1.0/gems
directory). This, combined with Oliver's answer about rbenv, got me thinking about mismatched versions.
I reinstalled bundler with a simple gem install bundler
, reran bundle install
, and all is good.
It seems in general the answer is to sort out issues with bundler installing for a different version of Ruby than you're actually using. It seems strange to me it would use one thing for bundle install
and another for bundle exec
, but *shrug* whatever.
Related Topics
Hardcoded "Require 'Debug'" Can't Find the Sourcefile
What Is a More Ruby-Like Way of Doing This Command
How to Access HTML Elements That Are Rendered in JavaScript Using Xpath
How to Create Automatically a Instance of Every Class in a Directory
Incompatible Character Encoding in Rails - How to Just Fail/Skip Sensibly
How to Download File from Google Drive API with Service Account
How to Split a String of Repeated Characters with Uneven Amounts? Ruby
Gitlab: Invocation of Gitlab-Shell
Elegant Way to Only Show Records If They Exist in Rails Erb
Ruby: Calculate Time Difference Between 2 Times
Ruby: Module, Mixins and Blocks Confusing
Restart Rails Server Automatically After Every Change in Controllers
Are There Any Additional Inject Shorthand
I Trying to Make a Code That Gives the User a Personal Number After They Have Made an User
Disabling Irb Autocomplete on Heroku
Pass Arguments by Reference to a Block with the Splat Operator