Rails不能要求' nokogiri / nokogiri&#39 ;,尽管IRB可以

时间:2018-01-29 23:01:58

标签: ruby-on-rails rubygems nokogiri

首先,尽管我们几乎完全相同的标题,this post并没有解决这个问题。

两天前我在开发模式下运行rails,一切都很好。今天我启动服务器,遇到以下错误:

ooo = one()
ooo.start()

Process Loop
Thread Loop
{'hi': 1}
Process Loop
YES
{'hi': 1}
Process Loop
YES
{'hi': 1}
Process Loop

我总结的意思是当rails调用`require' nokogiri / nokogiri' rails无法找到gem并且失败了。我的第一个想法是检查,看看我是否有宝石,所以我打电话给

/Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/nokogiri-1.8.1/lib/nokogiri.rb:33:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/nokogiri-1.8.1/lib/nokogiri.rb:33:in `rescue in <top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/nokogiri-1.8.1/lib/nokogiri.rb:29:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/loofah-2.1.1/lib/loofah.rb:3:in `require'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/loofah-2.1.1/lib/loofah.rb:3:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/rails-html-sanitizer-1.0.3/lib/rails-html-sanitizer.rb:2:in `require'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/rails-html-sanitizer-1.0.3/lib/rails-html-sanitizer.rb:2:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/actionview-5.1.4/lib/action_view/helpers/sanitize_helper.rb:2:in `require'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/actionview-5.1.4/lib/action_view/helpers/sanitize_helper.rb:2:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/actionview-5.1.4/lib/action_view/helpers.rb:58:in `require'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/actionview-5.1.4/lib/action_view/helpers.rb:58:in `<module:Helpers>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/actionview-5.1.4/lib/action_view/helpers.rb:4:in `<module:ActionView>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/actionview-5.1.4/lib/action_view/helpers.rb:3:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/context.rb:1:in `require'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/context.rb:1:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/railtie.rb:7:in `require'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/railtie.rb:7:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/sass-rails-5.0.6/lib/sass/rails/railtie.rb:3:in `require'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/sass-rails-5.0.6/lib/sass/rails/railtie.rb:3:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/sass-rails-5.0.6/lib/sass/rails.rb:11:in `require'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/sass-rails-5.0.6/lib/sass/rails.rb:11:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/sass-rails-5.0.6/lib/sass-rails.rb:1:in `require'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/sass-rails-5.0.6/lib/sass-rails.rb:1:in `<top (required)>'
from /Users/martin/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in `require'
from /Users/martin/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
from /Users/martin/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `each'
from /Users/martin/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `block in require'
from /Users/martin/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `each'
from /Users/martin/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `require'
from /Users/martin/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler.rb:114:in `require'
from /Users/martin/Desktop/hotline/config/application.rb:7:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:133:in `require'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:133:in `block in perform'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `tap'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `perform'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
from /Users/martin/Desktop/hotline/bin/rails:9:in `require'
from /Users/martin/Desktop/hotline/bin/rails:9:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
from /Users/martin/Desktop/hotline/vendor/bundle/ruby/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
from /Users/martin/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:70:in `require'
from /Users/martin/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:70:in `require'
from /Users/martin/Desktop/hotline/bin/spring:15:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'

我的下一个想法是重新加载nokogiri,所以我卸载并重新安装了一些,并重新启动我的Mac,但无济于事。

我在网上搜索了一个咒语,而我发现遇到同样问题的最接近的人解决方案是Windows存在兼容性问题。这非常无益,因为我有一台Mac。

现在,我甚至不知道自己不知道什么。为什么这个错误会被解雇?从现在和两天前我的计算机上发生了什么变化来发生此错误?我需要做些什么来解决这个问题?

1 个答案:

答案 0 :(得分:0)

叹息 我发现了这个问题。如果您将最新项目保留在桌面上,就像我一样,Mac OS会尝试通过将文件上传到云来节省磁盘空间。如果您的应用程序的一半在云中,当您尝试运行本地主机时,您的应用程序的一半将不在那里。我从云端重新下载了文件,它运行得很好。