title: nokogiri gem - ERROR: Failed to build gem native extension.
body: <p>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</p>
  
  <p>The backtrace is the following:</p>
  
  <pre><code>Tasks: TOP =&gt; deploy:updated =&gt; 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&gt;&amp;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
  </code></pre>
  
  <p>I ran the command</p>
  
  <pre><code>sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
  </code></pre>
  
  <p>in my server, and if I run "gem install nokogiri" the gem is installed normally.</p>
  
  <p>I hope someone can help me to fix the error.</p>