【问题标题】:Why did I get "LoadError: cannot load such file -- nokogiri"?为什么我会收到“LoadError: cannot load such file -- nokogiri”?
【发布时间】:2015-10-04 12:34:51
【问题描述】:

我正在尝试将我的 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'

【问题讨论】:

  • 欢迎来到 Stack Overflow。询问时,请不要使用屏幕截图来显示文本,尤其是错误。而是复制并粘贴消息的相关部分,这样我们就可以复制和粘贴我们需要的内容。它可以帮助我们帮助您。此外,链接总是会断开,这会使您的图片无法显示,从而使其他人很难说出您在说什么。

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


【解决方案1】:

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

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

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

nokogiri (1.6.6.2-x86-mingw32)

nokogiri (1.6.6.2)

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

【讨论】:

  • 嘿,谢谢!但我现在遇到另一个错误:“Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded”。我的 gemfile 中已经有 gem 'mysql2', '~> 0.3.18' 所以我不知道什么是真正的错误?
  • 我对 mysql gem 不熟悉,但我猜它需要安装 MySQL 数据库。 ssh 到服务器并在部署应用程序之前执行sudo apt-get install mysql-server mysql-client libmysqlclient-dev。这是一个可能有用的链接:gorails.com/deploy/ubuntu/14.04
  • 嘿,我已经解决了!感谢您的回答..从我的 Gemfile.lock 中的 gem 版本中删除所有 -x86-mingw32 后,我需要先将此更新推送到我的 Github 存储库,然后再将其部署到服务器:)
猜你喜欢
  • 2014-03-08
  • 2023-04-10
  • 2022-01-21
  • 1970-01-01
  • 2023-03-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多