1

i'm trying to deploy a rails application with capistrano but i'm having some problems with nokogiri gem when is bundle installing in the server ubuntu 16.04

The backtrace is the following:

Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as root@104.236.11.204: bundle exit status: 5
bundle stdout: Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/var/www/denunciabarranquillafinal/shared/bundle/ruby/2.3.0/gems/nokogiri-1.8.1/ext/nokogiri
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20171113-30499-1nk84ws.rb
extconf.rb --use-system-libraries
Cannot allocate memory - /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r
./siteconf20171113-30499-1nk84ws.rb extconf.rb --use-system-libraries 2>&1

Gem files will remain installed in
/var/www/denunciabarranquillafinal/shared/bundle/ruby/2.3.0/gems/nokogiri-1.8.1
for inspection.
Results logged to
/var/www/denunciabarranquillafinal/shared/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.1/gem_make.out

An error occurred while installing nokogiri (1.8.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.8.1'` succeeds before bundling.

In Gemfile:
  rails was resolved to 4.2.4, which depends on
    actionmailer was resolved to 4.2.4, which depends on
      actionpack was resolved to 4.2.4, which depends on
        actionview was resolved to 4.2.4, which depends on
          rails-dom-testing was resolved to 1.0.8, which depends on
            nokogiri
bundle stderr: Nothing written

I ran the command

sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev

in my server, and if I run "gem install nokogiri" the gem is installed normally.

I hope someone can help me to fix the error.

ricprogrammer
  • 25
  • 1
  • 5
  • 1
    Did you not just fix the problem by installing the needed packages? – Qwertie Nov 14 '17 at 00:21
  • Duplicate ? https://stackoverflow.com/questions/42481130/cannot-install-rails-gem-on-ruby-2-3-1 – Tachyons Nov 14 '17 at 01:22
  • when it says "Make sure that `gem install nokogiri -v '1.8.1'` succeeds before bundling.", you should try that. It will show you more specific errors. – max pleaner Nov 14 '17 at 01:37
  • I fixed running `gem install bundler` in my server. :) – ricprogrammer Nov 14 '17 at 02:26
  • Possible duplicate of [Error installing nokogiri: Failed to build gem native extension & libiconv is missing (OSX)](https://stackoverflow.com/questions/33996523/error-installing-nokogiri-failed-to-build-gem-native-extension-libiconv-is-mi) – anothermh Nov 14 '17 at 05:39

2 Answers2

1

try this :

$ sudo apt-get update 
$ sudo apt-get install libxml2-dev libxslt-dev
$ sudo gem install nokogiri
vipin
  • 2,374
  • 1
  • 19
  • 36
0

I know this is years after this thread started, but i had this same problem with nokogiri and capybara. I'm on Ubuntu 20.04, but had the same issue on Ubuntu 18.04 - same computer.

sudo apt-get update
sudo apt-get install gcc ruby-dev libxslt-dev libxml2-dev zlib1g-dev
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
sudo apt-get install libxml2-dev libxslt-dev
sudo gem install nokogiri
sudo gem install capybara

I tried everything I could find, but nothing seemed to work. I'm not sure what did it, but above are the last commandline commands I tried. Poof... It worked finally.

John Cowan
  • 1,452
  • 5
  • 25
  • 39