为什么我得到“LoadError:无法加载这样的文件 - nokogiri”?

时间:2015-10-04 12:34:51

标签: ruby-on-rails ruby capistrano nokogiri digital-ocean

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

LoadError: cannot load such file -- nokogiri

当我跑

cap production deploy:initial

来自我的本地机器。我从未在我的Gemfile中使用Nokogiri或者为我的应用程序安装了它。

这是错误:

enter image description here

这是我的宝石文件:

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'

1 个答案:

答案 0 :(得分:1)

Nokogiri是您正在使用的其中一颗宝石的依赖。

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

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

nokogiri (1.6.6.2-x86-mingw32)

nokogiri (1.6.6.2)

Nokogiri不会是您手动编辑的唯一宝石版本,因此在其版本中搜索其他宝石-x86-mingw32。至少还会pgvoid array(char *s){ if(*s=='\0') return; array(++s); printf("%c",*s); } 。它在部署期间不会导致错误,如果在Windows上生成Gemfile.lock,它就不会安装。