【问题标题】:Failed to deploy app via Capistrano, LoadError: cannot load such file -- nokogiri无法通过 Capistrano 部署应用程序,LoadError: cannot load such file -- nokogiri
【发布时间】:2015-07-10 09:39:00
【问题描述】:

我正在使用this tutorial to deploy my app to VPS。我在 DigitalOcean 上创建了 Ubuntu 服务器。我已经完成了所有这些步骤。但是在第 11 步,我必须编写此代码:

bundle exec cap production deploy

它给我一个错误:

rake aborted!
DEBUG [280721fe]        LoadError: cannot load such file -- nokogiri
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/loofah-2.0.2/lib/loofah.rb:3:in `require'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/loofah-2.0.2/lib/loofah.rb:3:in `<top (required)>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/rails-html-sanitizer-1.0.2/lib/rails-html-sanitizer.rb:2:in `require'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/rails-html-sanitizer-1.0.2/lib/rails-html-sanitizer.rb:2:in `<top (required)>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/sanitize_helper.rb:3:in `require'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/sanitize_helper.rb:3:in `<top (required)>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/text_helper.rb:32:in `<module:TextHelper>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/text_helper.rb:29:in `<module:Helpers>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/text_helper.rb:6:in `<module:ActionView>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/text_helper.rb:4:in `<top (required)>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/form_tag_helper.rb:18:in `<module:FormTagHelper>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/form_tag_helper.rb:14:in `<module:Helpers>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/form_tag_helper.rb:8:in `<module:ActionView>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/form_tag_helper.rb:6:in `<top (required)>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/form_helper.rb:4:in `require'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers/form_helper.rb:4:in `<top (required)>' 
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers.rb:50:in `<module:Helpers>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers.rb:4:in `<module:ActionView>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/actionview-4.2.0/lib/action_view/helpers.rb:3:in `<top (required)>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/legacy_asset_tag_helper.rb:7:in `<module:LegacyAssetTagHelper>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/legacy_asset_tag_helper.rb:6:in `<module:Rails>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/legacy_asset_tag_helper.rb:4:in `<module:Sprockets>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/legacy_asset_tag_helper.rb:3:in `<top (required)>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/helper.rb:54:in `require'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/helper.rb:54:in `<module:Helper>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/helper.rb:7:in `<module:Rails>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/helper.rb:6:in `<module:Sprockets>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/helper.rb:5:in `<top (required)>'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/railtie.rb:6:in `require'
DEBUG [280721fe]        /var/www/newsapp/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/railtie.rb:6:in `<top (required)>'
DEBUG [280721fe]        /var/www/newsapp/releases/20150710090114/config/application.rb:10:in `require'
DEBUG [280721fe]        /var/www/newsapp/releases/20150710090114/config/application.rb:10:in `<top (required)>'
DEBUG [280721fe]        /var/www/newsapp/releases/20150710090114/Rakefile:4:in `require'
DEBUG [280721fe]        /var/www/newsapp/releases/20150710090114/Rakefile:4:in `<top (required)>'
DEBUG [280721fe]        (See full trace by running task with --trace)

Ubuntu 无法加载 nokogiri。我在它尝试运行rake assets:precompile 命令时发生。

我在 Windows 7 上编写了这个项目并将其上传到我的 BitBucket 存储库。我以为 Capistrano 自己运行 bundle install 并更改 Gemfile.lock

我在 Windows 7 x64 上运行的本地计算机使用 Ruby 2.1.5。

我在 Ubuntu Server 14.04 x64 上运行的 VPS 使用 Ruby 2.2.0。

我需要做什么?

==== 更新 ====

我想,因为我已经在 Windows 上编写了这个应用程序并尝试将其上传到 Ubuntu,所以我的 Gemfile.lock 会有所不同。我已删除它并尝试将其上传到我的 VPS,它说它无法运行我的应用程序,因为我没有Gemfile.lock

==== 更新 ====

我已经重启了我的 VPS。我听说 Nokogiri 与 Ruby 的 2.2 版本有冲突,所以我安装了 2.1.6 版本。仍然在预编译时给我这个错误。

==== 更新 ====

我发现在我的 Ubuntu 每一个我想开始的 rake 任务中都会抛出这个错误。

【问题讨论】:

  • Capistrano 自己不会做任何事情,,,, 如果你在 deploy.rb 中指定这个,只有这样它才会这样做,否则它不会
  • 我查看了控制台日志,发现它运行 bundler Running /usr/bin/env bundle install --path /var/www/newsapp/shared/bundle --without development test --deployment --quiet。但是它仍然在预编译时出错。这样做是因为我的项目是在 Windows 上编写的吗?
  • 你有来自bundle install的输出吗? nokogiri 需要 libxml2libxslt - 你的 VPS 上安装了吗?

标签: ruby-on-rails ruby ubuntu capistrano nokogiri


【解决方案1】:

我了解到 Nokogiri 在 Ruby (2.2) 的最新版本中存在一些问题,您可能应该考虑在您的服务器上回滚到 Ruby 2.1。

【讨论】:

  • 请链接到如何回滚或示例:)
  • 我在你使用的教程中看到那个家伙建议通过rbenv 安装 ruby​​。我对它不是很熟悉,因为我更喜欢使用 RVM,但你绝对应该在官方 rbenv 文档中找到你的答案:github.com/sstephenson/rbenv希望它有所帮助
  • 我已经重新启动了我的 VPS 并安装了 2.1.6 版本的 Ruby。它仍然给我这个错误。
【解决方案2】:

我找到了解决方案,但我认为它并不好。

在我的Gemfile.lock 中,我删除了所有-64x-mingw 字符串,只留下了我的宝石的名称和版本号。

在平台上我只是写了ruby而不是mingw

嗯……那行得通。

Heroku 删除 Windows Gemfile.lock 并自动生成新的。是否可以向 capistrano 发送此类命令?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    • 2014-03-08
    • 2022-01-21
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多