Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bundler not working with rbenv, could not find [gem]

I've just made the switch from rvm to rbenv and I'm trying to use bundler for gem management. After running bundle install and trying to run a simple sinatra app (ruby app.rb), I get this:

Could not find haml-3.1.4 in any of the sources Run `bundle install` to install missing gems. 

Running bundle install again had no effect. Also tried bundle update as suggested by another question response.

This is my Gemfile:

source "http://rubygems.org"  gem "sinatra" gem "haml" 

This is what bundle show produces

* bundler (1.0.22) * haml (3.1.4) * rack (1.4.1) * rack-protection (1.2.0) * sinatra (1.3.2) * tilt (1.3.3) 

This is what my app requires:

require "rubygems" require "bundler/setup" require 'sinatra' 

I'm convince that this is some kind of path issue where bundler and rbenv aren't playing along. I've tried looking through rbenv's documentation but was not able to find to anything.

Note: In a different sinatra app I get the following when trying to run it:

Could not find addressable-2.2.7 in any of the sources Run `bundle install` to install missing gems. 

Supplemental info

echo $PATH
/Users/uri/.rbenv/shims:/Users/uri/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

which bundle
/Users/uri/.rbenv/shims/bundle

Update

If I do bundle install --system it works. Although I can't see this as being a viable solution.

like image 950
Uri Avatar asked Mar 07 '12 13:03

Uri


People also ask

Where does bundler install gems?

Show activity on this post. I know that when using gem install , the gem will be stored under /home/username/. rvm/gems/, under which gemset the gem was installed.

How do I install bundles to install missing gems?

In the invoked popup, start typing bundler, select bundle install and press Enter . Select Tools | Bundler | Install from the main menu. Open the Gemfile, place the caret at any highlighted gem missing in the project SDK and press Alt+Enter . Select Install missing gems using 'bundler' and press Enter .

What does Rbenv rehash do?

Through a process called rehashing, rbenv maintains shims in that directory to match every Ruby command across every installed version of Ruby— irb , gem , rake , rails , ruby , and so on. Shims are lightweight executables that simply pass your command along to rbenv.


1 Answers

I was having the same issue. One hint was that rbenv exec bundle exec command worked and that rbenv exec bundle install --path vendor/bundle worked, but their prefixed equivalents failed.

I wiped my ~/.rbenv, ~/.gem Gemfile.lock and vendor/bundle a few times trying to start fresh. Once these were cleaned away I tried the following:

rbenv install 1.9.3-p194 rbenv rehash # for paranoia's sake rbenv global 1.9.3-p194 gem env # to check that everything was pointing at 1.9 and not the system gem install --no-ri --no-rdoc bundler rbenv rehash # necessary to load up the bundle executable bundle --path=vendor/bundle 

and it worked!

I think the important thing, since I tried this a few times, is to remove the .gem file from your home directory. It seems to get in the way.

like image 184
kweerious Avatar answered Sep 27 '22 22:09

kweerious