1

My cap production deploy is failing on nokogiri installation on an Ubuntu 12.04 box:

DEBUG [6f355ce8]    Extracting libxml2-2.8.0.tar.gz into tmp//ports/libxml2/2.8.0... OK
DEBUG [6f355ce8]    Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp//ports/libxml2/2.8.0/configure.log' to see what happened.
DEBUG [6f355ce8]    *** extconf.rb failed ***
DEBUG [6f355ce8]    Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling.

I checked said logs and it mentions not finding a C compiler. I tried to install the dependencies for ubuntu on the nokogiri site and the system says they are already installed.

I also tried gem install nokogiri -v '1.6.1' on the server and it succeeds with no issues, gem list shows it installed on the server.

I found a similar question that suggested adding this line to the production.rb

set :bundle_env_variables, { 'NOKOGIRI_USE_SYSTEM_LIBRARIES' => 1 }

Which changes the error to be a bit more specific:

DEBUG [1e93b004]    /usr/local/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:430:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
DEBUG [1e93b004]    You have to install development tools first.

But trying to install them via:

sudo apt-get install libxslt-dev libxml2-dev

says everything is already installed --and again, nokogiri installs fine outside of the deploy task.

user2936314
  • 1,734
  • 4
  • 18
  • 32
  • 1
    Is there any chance you are using rvm on the server and have not created the correct gemset? If so, try installing nokogiri manually on that gemset. – xlembouras Apr 13 '14 at 10:02
  • I'm using rbenv, sorry forgot to mention it – user2936314 Apr 13 '14 at 10:15
  • 1
    I would suggest you tried `bundle install` manually (as the same user capistrano uses). If that goes well you'll know it is a capistrano configuration problem. – xlembouras Apr 13 '14 at 10:18
  • The bundle install works as root, but not as the deploy user. Maybe because of installing nokogiris' dependencies with sudo? – user2936314 Apr 13 '14 at 11:44
  • You should always try to bundle install as the user. If that fails because of missing libraries, you install them (as root) and then try again bundling (as non root) – xlembouras Apr 13 '14 at 13:57

1 Answers1

1

I was missing one of the ruby dev dependencies for ubuntu: http://nokogiri.org/tutorials/installing_nokogiri.html

Also, for some reason this server only gave root permissions to access some of the nokogiri dependencies, I had to chmod them for my deploy user.

user2936314
  • 1,734
  • 4
  • 18
  • 32
  • That is a bad sign, most likely it will disturb you in the future – xlembouras Apr 13 '14 at 13:59
  • Yes, there's been a few weird permissions errors on this server and I'm starting to think about dumping it and going with another provider. Couldn't use one of the usual suspects because client wants it hosted in a specific country – user2936314 Apr 13 '14 at 22:42