我没有对我的Rails应用程序进行任何更改,但是当我去运行rails s
时,它给了我这个错误:
/usr/local/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.1/lib/nokogiri.rb:32:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
from /usr/local/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.1/lib/nokogiri.rb:32:in `rescue in <top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.1/lib/nokogiri.rb:28:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/loofah-2.1.1/lib/loofah.rb:3:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/loofah-2.1.1/lib/loofah.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/rails-html-sanitizer-1.0.3/lib/rails-html-sanitizer.rb:2:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/rails-html-sanitizer-1.0.3/lib/rails-html-sanitizer.rb:2:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/actionview-5.0.6/lib/action_view/helpers/sanitize_helper.rb:2:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/actionview-5.0.6/lib/action_view/helpers/sanitize_helper.rb:2:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/actionview-5.0.6/lib/action_view/helpers.rb:58:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/actionview-5.0.6/lib/action_view/helpers.rb:58:in `<module:Helpers>'
from /usr/local/lib/ruby/gems/2.4.0/gems/actionview-5.0.6/lib/action_view/helpers.rb:4:in `<module:ActionView>'
from /usr/local/lib/ruby/gems/2.4.0/gems/actionview-5.0.6/lib/action_view/helpers.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/context.rb:1:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/context.rb:1:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/railtie.rb:7:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/railtie.rb:7:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/sass-rails-5.0.6/lib/sass/rails/railtie.rb:3:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/sass-rails-5.0.6/lib/sass/rails/railtie.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/sass-rails-5.0.6/lib/sass/rails.rb:11:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/sass-rails-5.0.6/lib/sass/rails.rb:11:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/sass-rails-5.0.6/lib/sass-rails.rb:1:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/sass-rails-5.0.6/lib/sass-rails.rb:1:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:81:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:76:in `each'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:76:in `block in require'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:65:in `each'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/runtime.rb:65:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler.rb:114:in `require'
from /Users/jenyoung/Documents/Testing/Rails-Test/config/application.rb:7:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:88:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:88:in `block in server'
from /usr/local/lib/ruby/gems/2.4.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /usr/local/lib/ruby/gems/2.4.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:85:in `server'
from /usr/local/lib/ruby/gems/2.4.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /usr/local/lib/ruby/gems/2.4.0/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
from /Users/jenyoung/Documents/Testing/Rails-Test/bin/rails:9:in `require'
from /Users/jenyoung/Documents/Testing/Rails-Test/bin/rails:9:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
from /usr/local/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
from /usr/local/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
from /usr/local/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
from /usr/local/lib/ruby/gems/2.4.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
from /usr/local/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
from /usr/local/Cellar/ruby/2.4.2_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
from /usr/local/Cellar/ruby/2.4.2_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
from /Users/jenyoung/Documents/Testing/Rails-Test/bin/spring:15:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
我已成功运行bundle install
,但我仍然看到上述错误。
这可能是我的Rails的配置问题以及它在哪里寻找宝石?如果是这样,我如何设置它来代替./vendor/gems/ruby/2.4.0
中的宝石?
我还尝试了gem install
列出的各种宝石。
这是我的Ruby和Rails所在的位置:
$ which ruby
/usr/local/bin/ruby
$ which -a ruby
/usr/local/bin/ruby
/usr/local/bin/ruby
/usr/local/bin/ruby
/usr/bin/ruby
$ which rails
/usr/local/bin/rails
$ which -a rails
/usr/local/bin/rails
/usr/local/bin/rails
/usr/local/bin/rails
/usr/bin/rails
$ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
$ rails -v
Rails 5.0.6
我在OSX 10.12.6 - Sierra。
的Gemfile:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.1'
# Use sqlite3 as the database for Active Record
# Use Puma as the app server
gem 'puma', '~> 3.0'
# 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.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'hellosign-ruby-sdk'
gem 'dotenv-rails', groups: [:development, :test]
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'nokogiri'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'httparty'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
gem 'sqlite3'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :production do
gem 'pg'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
所以我也尝试创建一个全新的rails应用程序并运行rails s,它也会给我一个类似的错误:
/usr/local/lib/ruby/gems/2.4.0/gems/sqlite3-1.3.13/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
答案 0 :(得分:0)
删除所有gems的gem版本,为您提供此错误。例如,更改gem&#39; uglifier&#39;,&#39;&gt; = 1.3.0&#39;宝石&#39; uglifier&#39;为所有产生错误的宝石执行此操作。如果它不起作用,请不要捆绑安装,只捆绑(仅适用于旧版本的捆绑包)新版本的捆绑包(即捆绑包pre--)捆绑和安装,而旧版本只捆绑。