bson_ext 1.7.0 fails to build on Linux when using bundle:install Capistrano task - ruby

Here is the error message:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
Gem files will remain installed in /var/www/app_dir/shared/bundle/ruby/1.8/gems/bson_ext-1.7.0 for inspection.
Results logged to /var/www/app_dir/shared/bundle/ruby/1.8/gems/bson_ext-1.7.0/ext/cbson/gem_make.out
An error occured while installing bson_ext (1.7.0), and Bundler cannot continue.
Make sure that `gem install bson_ext -v '1.7.0'` succeeds before bundling.
I tried running gem install bson_ext -v '1.7.0' and this succeeded with no errors. I've tried installing ruby-dev and ruby1.8-dev apt packages and this did not help.
bundle install is able to successfully build bson_ext on my Mac OS X development system but is failing in the Linux production environment even when I run it directly outside of the context of the capistrano bundle:install task.
I have also tried running gem update --system and gem update bundler and this didn't help.
I suspect the issue lies in how bundle install is called on the target system. Still, I tried updating Capistrano to version 2.13.5 and this did not help.

So, it appears that bundler 1.2.1 is is unable to build the following gems on my system:
bson_ext 1.7.0
curb 0.8.3
nokogiri 1.5.5
json 1.7.5
therubyracer 0.8.2.
I was able to build these using gem install <GEMNAME> -v '<VERSION>' --install-dir /var/www/<APP_DIR>/shared/bundle/ruby/1.8/. After this, running bundle exec capistrano deploy succeeded.
bundle does not appear to be able to build gems with native extensions on my system. Not sure why, but maybe this procedure will help those with a similar issue.

Related

Error installing nokogiri: invalid gem: package is corrupt

I'm trying to parse a website by using jekyll on my Debian x64 and I get a problem with this following gem nokogiri , in particular I've been required on install the version 1.8.5 , but as it was not working I attempted downloading the last version nokogiri (1.11.0.rc2) Manualy from the web and now I'm stuck with this error.
bundle exec jekyll serve
Could not find nokogiri-1.8.5 in any of the sources
Run `bundle install` to install missing gems.
bundle install
Bundler::GemspecError: Could not read gem at
/var/lib/gems/2.7.0/cache/nokogiri-1.8.5.gem. It may be corrupted.
An error occurred while installing nokogiri (1.8.5), and Bundler
cannot continue.
Make sure that `gem install nokogiri -v '1.8.5' --source
'https://rubygems.org/'` succeeds before bundling.
I think you don't have it's dependancy library libxml2 try running below code.
brew install libxml2
if not worked add nokogiri gem using below command
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]

Unable to install bcrypt-ruby, blocks upgrade of devise, "Failed to build native gem extension"

I'm on Mac OSX 10.10.2. In attempting to upgrade devise from 2.1.2 to 2.2.8 (by updating the version in the Gemfile), bundle install attempts to install bcrypt 3.1.10 and crashes with this output:
/Users/username/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
creating Makefile
make clean
make
compiling bcrypt_ext.c
make: *** [bcrypt_ext.o] Segmentation fault: 11
make failed, exit code 2
I have attempted some fixes found in searching, such as:
`gem install bcrypt -v '3.1.10'ยด
(same error)
Download gem source from github (https://github.com/codahale/bcrypt-ruby) and attempt to install from the local gemfile (same error).
Uninstall bcrypt-ruby with gem uni bcrypt, reinstalling with gem i bcrypt-ruby --platform=ruby (same error)
If I set user to root with sudo su -, I am able to run the install with the following output:
root# gem install bcrypt -v '3.1.10'
Building native extensions. This could take a while...
Successfully installed bcrypt-3.1.10
Parsing documentation for bcrypt-3.1.10
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for lib/bcrypt_ext.bundle, skipping
1 gem installed
However, if I exit out of root, bundle install still fails.
Running rvm 1.25.3, ruby 1.9.3, gem 2.2.2, Bundler version 1.9.4, Xcode 6.3, Command Line Tools 6.3
Any ideas?
Finally, this worked:
Updating RVM to head with rvm get head
Uninstall rvm 1.9.3 with rvm uninstall 1.9.3
Re-install rvm 1.9.3. Tried running rvm install 1.9.3, which advised to run rvm install ruby-1.9.3-p551 instead. Did that.
rvm use 1.9.3
Reinstalled bundler with gem install bundler
Now, finally bundle install works.
It seems likely that previous steps (particularly running updates on Xcode & Command Line Tools) have contributed to success.

bundle install fails on nokogiri

I'm installing some chef dependencies following this website:
https://learnchef.opscode.com/starter-use-cases/multi-node-ec2/
I got to the bundle install part, here's what my Gemfile looks like:
source 'https://rubygems.org'
gem 'berkshelf'
gem 'chef'
gem 'knife-ec2'
I get this error when I try to run
bundle install --path vendor:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
...
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
...
An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.
I went to the nokogiri site and I was able to follow the directions and successfully install nokgiri 1.6.0 with homebrew .9.5:
nokogiri --version
WARNING: Nokogiri was built against LibXML version 2.9.1, but has dynamically loaded 2.8.0
# Nokogiri (1.6.0)
I get the same message when I then try running the bundle install again. I'm told that the bundle installer doesn't care about installs done outside of it. How to I get around this and install these dependencies?
After a little digging, I figured it out. This is specifically for OSX Mountain Lion.
The rbenv bundler needs to know the same paths specified using these switches given by the nokogiri site:
http://nokogiri.org/tutorials/installing_nokogiri.html
This is done using the bundler config command:
bundle config build.nokogiri --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar /libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
I still ran into troulbe because the config was only picking up the first line of that config setting. I had to edit $HOME/.bundle/config and take out some newlnes before it would take all of the switches. I hope this will save someone else some time.

Problems installing gems with RubyGems

I'm using Debian 5
Ruby version 1.8.7
Rubygems version 2.0.3
Rails version 3.2.12
I made my Ruby on Rails app and want to deploy it publicly, so I tried to install "Mongrel" without any luck and then "Unicorn" also without any luck and same error.
vps1198019:~# gem install mongrel
Building native extensions. This could take a while...
ERROR: Error installing mongrel:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/ext/http11/gem_make.out
and
vps1198019:~# gem install unicorn
Building native extensions. This could take a while...
ERROR: Error installing unicorn:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/kgio-2.8.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/kgio-2.8.0/ext/kgio/gem_make.out
Try using below command. Because of version mismatch, gem is not installed.
$ gem install mongrel --pre
So I found a solution for my problem by installed it more manually. I downloaded Unicorn from http://rubyforge.org/frs/?group_id=1306 (.gem file). Stored it in server. Went to that folder with terminal. Then I accessed it with
gem install --local unicorn.gem
Then it prompted that I must have kgio and raindrops so I installed them:
gem install kgio
gem install raindrops
and repeated first command.

bcrypt-ruby won't install with bundler but works fine with gem install

I just recently began having trouble with bundler - bcrypt-ruby will not install when doing a bundle install or sudo bundle install and exits with the following error:
Installing bcrypt-ruby (2.1.4) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
Gem files will remain installed in /home/deploy/vendor/bundle/ruby/1.8/gems/bcrypt-ruby-2.1.4 for inspection.
Results logged to /home/deploy/vendor/bundle/ruby/1.8/gems/bcrypt-ruby-2.1.4/ext/mri/gem_make.out
An error occured while installing bcrypt-ruby (2.1.4), and Bundler cannot continue.
Make sure that `gem install bcrypt-ruby -v '2.1.4'` succeeds before bundling.
However, gem install bcrypt-ruby -v '2.1.4' runs just fine (and in fact has already been run on this box). Running /usr/bin/ruby1.8 extconf.rb manually works just fine, and the resulting Makefile also runs with make just fine.
I'm using Ruby 1.8.7 and bundler 1.0.21 on Ubuntu 10.04.1 LTS. Other gems seem to be working fine through bundler. Though this is probably obvious, I've confirmed that the ruby-dev, gcc, etc packages are installed. I've tried using the --deployment option with bundler with no different behavior. The only thing I can think that has changed recently is I did a bundle update a couple days ago, so bundle got a minor version change (1.0.10 -> 1.0.21) and bcrypt appears to have gotten a major version change (2.1.4 -> 3.0.1).
Any help is appreciated!
Have you upgraded to Lion since you installed Ruby 1.9.2? If so it is probably linked to the wrong gcc.
Try uninstalling and reinstalling 1.9.2, I would suggest using rvm
rvm uninstall 1.9.2
rvm install 1.9.2
If that does not work you might have to implode rvm
rvm implode
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
source ~/.bash_profile
rvm install 1.9.2
try:
sudo apt-get install build-essential

Resources