Подтвердить что ты не робот

Ошибка о nokogiri при развертывании capistrano на сервере ubuntu

Пока bundle:install фаза после deploy:finalize_update, я получаю сообщение об ошибке nokogiri. Это предполагает,

 ** [out :: *******] Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.

Итак, я попытался установить nokogiri самостоятельно на сервере. Но он дает следующую ошибку,

Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /home/deployer/.rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-linux-gnu/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-linux-gnu/ports/libxml2/2.8.0/compile.log' to see what happened.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/deployer/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
/home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.0/lib/mini_portile.rb:235:in `block in execute': Failed to complete compile task (RuntimeError)
    from /home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.0/lib/mini_portile.rb:227:in `chdir'
    from /home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.0/lib/mini_portile.rb:227:in `execute'
    from /home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.0/lib/mini_portile.rb:61:in `compile'
    from /home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.0/lib/mini_portile.rb:101:in `cook'
    from extconf.rb:101:in `block in <main>'
    from extconf.rb:119:in `call'
    from extconf.rb:119:in `block in <main>'
    from extconf.rb:109:in `tap'
    from extconf.rb:109:in `<main>'


Gem files will remain installed in /home/deployer/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.6.0 for inspection.
Results logged to /home/deployer/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out

Он только что начался сегодня. Также libxml2 уже установлен.

Любая идея?

Спасибо.

EDIT: Я не требую явно nokogiri в моем gemfile.

4b9b3361

Ответ 1

Я столкнулся с той же проблемой с Nokogiri 1.6.0. Проблема, как вы можете видеть из журналов, вызвана неудачной компиляцией libxml2, которая вместе с libxslt теперь поставляется встроенной в драгоценный камень и скомпилирована при ее установке.

Чтобы узнать, что именно произошло с компиляцией, просмотрите предложенный файл compile.log, который в вашем случае вы можете найти по адресу

/home/deployer/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.6.0/ext/nokogiri/tmp/x86_64-linux-gnu/ports/libxml2/2.8.0/compile.log

В качестве обходного пути (если у вас установлены libxml2-dev и libxslt-dev), вы можете сделать:

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install

Надеюсь, это поможет.

Ответ 2

Если вы используете Capistrano 3.x, вы можете сделать следующее в вашем файле deploy.rb (или конкретном окружении файла i.e. deploy/production.rb)

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

Таким образом вы избегаете переопределения задачи bundle install. Это задает заданные переменные env при запуске bundle install.

Ответ 3

Основываясь на ответе @zekus, я создал новую задачу в capistrano следующим образом:

  task :custom_bundle_install, roles: :app do
    run "cd /home/#{user}/apps/#{application}/releases/#{release_name} && NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install --gemfile /home/#{user}/apps/#{application}/releases/#{release_name}/Gemfile --path /home/#{user}/apps/#{application}/shared/bundle --deployment --quiet --without development test"
  end
  before "bundle:install", "deploy:custom_bundle_install"

Это сработало для меня довольно хорошо.

Ответ 4

Подключитесь к хосту с пользователем развертывателя, а не попробуйте установить пакет самостоятельно:

cd {your last release path}
bundle config build.nokogiri --with-xml2-include=/usr/include/libxml2/libxml
bundle install --gemfile Gemfile --path shared/bundle --deployment --quiet --without development test

Запустите кастрано вручную.

Это сработало для меня.