【问题标题】:capistrano deploy can't install nokogiricapistrano 部署无法安装 nokogiri
【发布时间】:2014-04-13 09:49:29
【问题描述】:

我的cap production deploy 在 Ubuntu 12.04 机器上安装 nokogiri 失败:

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.

我检查了上述日志,它提到没有找到 C 编译器。我尝试在 nokogiri 站点上安装 ubuntu 的依赖项,系统说它们已经安装。

我还在服务器上尝试了gem install nokogiri -v '1.6.1',它成功了,没有问题,gem list 显示它已安装在服务器上。

我发现了一个类似的问题,建议将此行添加到 production.rb

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

这会使错误更具体一点:

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.

但尝试通过以下方式安装它们:

sudo apt-get install libxslt-dev libxml2-dev

说一切都已经安装了 -- 再一次,nokogiri 在deploy 任务之外安装得很好。

【问题讨论】:

  • 您是否有机会在服务器上使用 rvm 并且没有创建正确的 gemset?如果是这样,请尝试在该 gemset 上手动安装 nokogiri。
  • 我用的是 rbenv,不好意思忘了提
  • 我建议您手动尝试bundle install(就像同一个用户 capistrano 使用的那样)。如果一切顺利,您就会知道这是一个 capistrano 配置问题。
  • 捆绑安装以 root 身份运行,但不能以 deploy 用户身份运行。可能是因为使用 sudo 安装了 nokogiris 的依赖项?
  • 您应该始终尝试以用户身份进行捆绑安装。如果由于缺少库而失败,则安装它们(以 root 身份),然后再次尝试捆绑(以非 root 身份)

标签: ruby-on-rails ubuntu capistrano nokogiri


【解决方案1】:

我缺少 ubuntu 的 ruby​​ 开发依赖项之一:http://nokogiri.org/tutorials/installing_nokogiri.html

此外,由于某种原因,此服务器仅授予 root 访问某些 nokogiri 依赖项的权限,我必须为我的部署用户 chmod 它们。

【讨论】:

  • 这是个坏兆头,很可能以后会打扰到您
  • 是的,这台服务器上出现了一些奇怪的权限错误,我开始考虑转储它并与另一个提供商合作。无法使用常见的嫌疑人之一,因为客户希望将其托管在特定国家/地区
猜你喜欢
  • 2015-09-22
  • 1970-01-01
  • 1970-01-01
  • 2015-10-25
  • 2015-02-14
  • 2016-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多