Romain Champourlier
Romain Champourlier

Reputation: 2360

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:

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:

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!

Upvotes: 6

Views: 3839

Answers (2)

Andrew Ashbacher
Andrew Ashbacher

Reputation: 989

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. ;)

Upvotes: 8

Muhammad Sannan Khalid
Muhammad Sannan Khalid

Reputation: 3137

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

Upvotes: 1

Related Questions