Why did I get "LoadError: cannot load such file -- nokogiri"?

Why did I get "LoadError: cannot load such file -- nokogiri"?

我正在尝试将我的 Ruby on Rails 应用程序部署到 DigitalOcean 服务器上,但是我得到了

LoadError: cannot load such file -- nokogiri

当我运行

cap production deploy:initial

从我的本地机器。我从来没有在我的 Gemfile 中需要 Nokogiri 或为我的应用程序安装它。

这是错误:

这是我的 gemfile:

source 'https://rubygems.org'

ruby "2.0.0"

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc


group :development, :test do

  gem 'mysql2', '~> 0.3.13'
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem "rails-erd"

  gem 'capistrano',           require: false
  gem 'capistrano-rvm',       require: false
  gem 'capistrano-rails',     require: false
  gem 'capistrano-bundler',   require: false
  #gem 'capistrano-passenger', require: false
  gem 'capistrano3-puma',     require: false

end

group :production do

  gem 'rails_12factor', '0.0.2'
  gem 'thin'
  gem 'puma'

end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

#bootstrap
gem 'bootstrap-sass', '~> 3.3.4.1'

gem "better_errors"

#for user authentication 
gem "devise"

gem 'rails_admin', '~> 0.6.8'

gem 'jquery-ui-rails'

Nokogiri 是您正在使用的 gem 之一的依赖项。

问题的最常见原因是在开发和生产中使用不同的操作系统,例如在 Windows 中开发并部署到 Linux。

最简单但不是最好的修复方法是编辑 Gemfile.lock 并从 gem 版本中删除所有 -x86-mingw32 引用。例如,替换

nokogiri (1.6.6.2-x86-mingw32)

nokogiri (1.6.6.2)

Nokogiri 不是您必须手动编辑的唯一 gem 版本,因此请搜索其他 gem 版本中包含 -x86-mingw32 的版本。至少也会有pg。它不会在部署期间导致错误,如果您的 Gemfile.lock 是在 Windows.

上生成的,它就不会安装