我正在使用本教程将我的应用程序部署到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.
我的VPS运行在Ubuntu Server 14.04 x64使用Ruby 2.2.0。
我需要做什么?
====更新====
我想,因为我在Windows上写了这个应用程序,并试图把它上传到Ubuntu上,我的Gemfile.lock
会有所不同。我已经删除了它,并试图将其上传到我的VPS,它说它不能运行我的应用程序,因为我没有Gemfile.lock
.
====更新====
我重新启动了VPS。我听说Nokogiri与Ruby的2.2版本有冲突,所以我安装了2.1.6版本。但是在预编译时还是会出现这个错误。
====更新====
我发现在我的Ubuntu 中,我想开始的每个rake任务都会抛出这个错误。
我读到Nokogiri在上一个版本的Ruby(2.2)中有一些问题,也许你应该考虑在你的服务器上回滚到Ruby 2.1。
我已经找到了解决方案,但我认为它并不好。
在我的Gemfile.lock
中,我删除了所有的-64x-mingw
字符串,只留下我的宝石的名称和版本号。
在平台上,我只是写了ruby
而不是mingw
。
嗯…这工作。
Heroku删除Windows Gemfile.lock
并自动生成新的。有可能向capistrano发送这种命令吗?