Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't fix 'bundle install' failing for gems with native extensions

I am deploying Ruby On Rails apps on an Amazon EC2 cloud server. The server is running on Amazon Linux alami-2011.02. I can't say the distro it's based on (from my search, RedHat/CentOS, but I'm newbie in that field).

I've installed my Ruby environment with RVM (installed as root). I've setup two rubies:

  • REE 1.8.7
  • Ruby 1.9.2-p290

For each Rails app I deploy, I create a separate RVM gemset.

Since I ran in this problem, I've refreshed completely the Ruby environment by running rvm implode.

Here are my environment versions:

ruby -v      ---> ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
rvm -v       ---> 1.8.1
gem -v       ---> 1.6.2
bundle -v    ---> Bundler version 1.0.18

After this rvm implode:

  • I installed again the 2 rubies
  • I created a gemset for a ree-1.8.7 app and installed the gems required -> no problem
  • I created a gemset for a ruby-1.9.2 app and installed the gems through Bundle -> no problem, even for the gems with native extensions
  • I created a gemset for another ruby-1.9.2, tried to install the gems through Bundle... here it comes again!

This is what I get know when performing bundle install (logged in as root):

Updating https://github.com/p7r/will_paginate.git
Fetching source index for http://rubygems.org/
Installing rake (0.9.2) 
Installing multi_json (1.0.3) 
Installing activesupport (3.1.0) 
Installing bcrypt-ruby (3.0.0) with native extensions /usr/local/rvm/scripts/rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /usr/local/rvm/scripts/rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 

Gem files will remain installed in /usr/local/rvm/scripts/rvm/gems/ruby-1.9.2-p290@app/gems/bcrypt-ruby-3.0.0 for inspection.
Results logged to /usr/local/rvm/scripts/rvm/gems/ruby-1.9.2-p290@app/gems/bcrypt-ruby-3.0.0/ext/mri/gem_make.out

    [ removed the backtrace ]

However, if i just use gem install bcrypt, the gem install correctly, and I can just use bundle install which will run until the next gem with native extensions...

I've had the same issue with a ruby-1.9.2-p180 install, I tried downgrading RubyGems to different versions until 1.5.3, I imploded my RVM... I've looked a lot on the web for answers, this problem seems recurrent, but nothing worked for me.

Thanks in advance for your help!

like image 250
Romain Champourlier Avatar asked Sep 07 '11 08:09

Romain Champourlier


People also ask

How do I fix a run bundle 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 .

How do I resolve gem dependencies?

Common Attempts To Resolve Ruby Gem Dependencies Bundler can help to resolve dependencies when working with Ruby gems by allowing you to specify a set of gems in a Gemfile, then issue a single command to install them. Bundler then automatically resolves the dependencies for you.

What is the difference between gem install and bundle install?

Almost seems like running 'gem install' adds it to the global available gems (and hence terminal can run the package's commands), whereas adding it to the gemfile and running bundle install only adds it to the application. Similar to npm install --global. that's basically it.

Where does bundle install gems to?

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.


2 Answers

This might be due to insufficient memory for compiling the native extensions. In my experience, bundle install is more memory intensive than simply using gem install. Take a look at /var/log/messages and see if any such issues are present. Also, use top to identify any heavyweight processes, like colleagues leaving rails console running in a screen session. ;)

like image 97
Andrew Ashbacher Avatar answered Sep 28 '22 18:09

Andrew Ashbacher


If you are running on linux you need to install libraries/packages before install bcrypt-ruby gem.

sudo apt-get install ruby1.8-dev //for ruby 1.8.7

or

sudo apt-get install ruby-dev

or

sudo apt-get install ruby1.9-dev //for ruby 1.9.2

now you can install bcrypt-ruby gem with following command

sudo gem install bcrypt-ruby
like image 41
Muhammad Sannan Khalid Avatar answered Sep 28 '22 17:09

Muhammad Sannan Khalid