Failed to deploy app via Capistrano, LoadError: cannot load such file -- nokogiri

Failed to deploy app via Capistrano, LoadError: cannot load such file -- nokogiri

我正在使用 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 运行s bundle install 自己改变 Gemfile.lock.

我的本地计算机 运行ning Windows 7 x64 使用 Ruby 2.1.5.

我的 VPS 运行ning 在 Ubuntu 服务器 14.04 x64 使用 Ruby 2.2.0.

我需要做什么?

====更新====

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

====更新====

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

====更新====

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

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

我找到了解决办法,但我觉得不好。

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

在平台中我简单地写了ruby而不是mingw

好吧……那行得通。

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