Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bundle install broken on ruby 2.0 upgrade

Just upgraded to ruby 2.0/rails 4.0 and trying to run bundle install on a new rails project. Whenever it hits something that's not already installed, it'll spit out:

Installing coffee-rails (4.0.0.beta1) 
Errno::ENOENT: No such file or directory - /usr/lib/ruby/gems/2.0.0/build_info/coffee-rails-4.0.0.beta1.info
An error occurred while installing coffee-rails (4.0.0.beta1), and Bundler cannot continue.
Make sure that `gem install coffee-rails -v '4.0.0.beta1'` succeeds before bundling.

So then I then run

gem install coffee-rails -v '4.0.0.beta1'

And it installs fine, and I rerun bundle install and have to repeat this for every time it runs into a gem version I haven't installed yet. What's the problem here?

like image 208
Chris Bolton Avatar asked Apr 07 '13 23:04

Chris Bolton


People also ask

How do I install bundles to install missing gems?

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 is the difference between bundle install and bundle update?

lock . In general, you should use bundle install(1) to install the same exact gems and versions across machines. You would use bundle update to explicitly update the version of a gem.

What is the difference between gem install and bundle install?

What's the difference? A Gemfile. lock is auto-generated & it says exactly what versions of every gem were installed. Bundler will install these versions so when you deploy this application to production, or share your project with other developers, everyone will be working with an identical set of gems.


2 Answers

In my case it turned out that bundle was trying to install gems into global location at /usr/lib/ruby/gems/2.0.0, but since I didn't invoke it through sudo it ended up with permission error. I wanted to install to my home dir anyhow so it turned out that I can do:

GEM_HOME=~/.gem/ruby/2.0.0/ bundle

and live happily ever after.

like image 92
kyku Avatar answered Oct 19 '22 08:10

kyku


The bundle executable is just a shell script, and it has a shebang line which will be pointing to a particular Ruby executable (or to /usr/bin/env ruby). It sounds like that shebang line is pointing to a different version of Ruby, not the 2.0 one, and not the one that the shebang line in your gem executable is pointing to.

Run this to see what it's pointing to: head -1 $(which bundle)

Whatever line that shows you, strip off the #! prefix and run that line with the -v switch to see which version of Ruby it is (if it's not obvious). So if the shebang line was #!/usr/bin/ruby then run /usr/bin/ruby -v If my theory is correct then you'll get a non 2.0 version number there.

Based on what you said, your gem executable is pointing to the 2.0 Ruby, so the fix here is to just uninstall and then reinstalled the bundler gem. That should put the right Ruby 2.0 shebang line into your bundle executable.

like image 20
smathy Avatar answered Oct 19 '22 07:10

smathy