[英]Rails server works, Rails console does not. `require': cannot load such file — bundler/setup (LoadError) -
I'm using rvm on mac osx 10.9.5: rvm 1.26.11 (latest) by Wayne E. Seguin , Michal Papis [ https://rvm.io/] 我在Mac OS X 10.9.5上使用RVM:Wayne E. Seguin和Michal Papis撰写的RVM 1.26.11(最新)[ https://rvm.io/]
Current ruby version in RVM: RVM中的当前Ruby版本:
=* ruby-2.2.3 [ x86_64 ] = *红宝石-2.2.3 [x86_64]
I'm not sure what exactly caused this behaviour, it could be that I updated homebrew. 我不确定是什么导致了此行为,可能是我更新了自制软件。
I also tried to disable spring by removing it from the gemfile, no luck. 我还尝试通过从gemfile中删除spring来禁用spring,但是没有运气。 Also note the paths in the stacktrace, for Spring it points to 2.1.3 instead of 2.2.3. 还要注意stacktrace中的路径,对于Spring,它指向2.1.3而不是2.2.3。 What could be going on here ? 这可能是怎么回事?
$ rails c
Ignoring libv8-3.16.14.13 because its extensions are not built. Try: gem pristine libv8 --version 3.16.14.13
Ignoring libv8-3.16.14.11 because its extensions are not built. Try: gem pristine libv8 --version 3.16.14.11
Ignoring oj-2.14.0 because its extensions are not built. Try: gem pristine oj --version 2.14.0
/Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/commands.rb:33:in `<module:Spring>'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/commands.rb:4:in `<top (required)>'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:77:in `preload'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:143:in `serve'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:131:in `block in run'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:125:in `loop'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application.rb:125:in `run'
from /Users/Laurens/.rvm/gems/ruby-2.1.3/ruby/2.2.0/gems/spring-1.4.4/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Laurens/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
$ rails s
=> Booting Thin
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:3000, CTRL+C to stop
After lots of trial and error, got it working by doing the following: 经过大量的试验和错误,通过执行以下操作使其工作:
bundle install
跑bundle install
spring stop
冉spring stop
spring binstub --all
冉spring binstub --all
(In the meanwhile I also updated my xcode, but not sure if this had any effect.) (与此同时,我也更新了我的xcode,但不确定这是否有效果。)
After this, rails c worked without the pristine & bundle errors. 在此之后,滑轨c可以正常工作,而不会出现原始和捆绑错误。
只需将spring更新为最新版本(1.6.4),请参阅https://github.com/rails/spring/issues/456以获取参考
have you tried this command? 您是否尝试过此命令?
gem pristine --all
If it does not help, try this one: 如果没有帮助,请尝试以下一种方法:
rvm get stable
You should also call your rails console command in the context of the bundle: 您还应该在捆绑软件的上下文中调用rails console命令:
bunde exec rails console
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.