简体   繁体   English

Rails服务器正常工作,Rails控制台无效。 `require':无法加载此类文件-捆绑程序/安装程序(LoadError)-

[英]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: 经过大量的试验和错误,通过执行以下操作使其工作:

  1. In my rails project folder there was an invisible file called ".bundle", I deleted this file, it somehow had references to 2.1.3 . 在我的rails项目文件夹中,有一个名为“ .bundle”的不可见文件,我删除了此文件,它以某种方式引用了2.1.3。
  2. Ran bundle install bundle install
  3. Ran spring stop spring stop
  4. Ran 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.

相关问题 Ruby on Rails:错误“require”:无法加载此类文件——bundler/setup (LoadError) - Ruby on Rails: Error `require': cannot load such file -- bundler/setup (LoadError) `require&#39;:无法加载此类文件-捆绑程序/安装程序(LoadError) - `require': cannot load such file — bundler/setup (LoadError) Rails 服务器和 Rails 控制台崩溃:要求&#39;:无法加载此类文件 -- 机架/保护 (LoadError) - Rails server and Rails console crash with: require': cannot load such file -- rack/protection (LoadError) Rails 控制台:在“require”中:无法加载此类文件 — readline (LoadError) - Rails console: in `require': cannot load such file — readline (LoadError) rails服务器抛出`require&#39;:无法加载这样的文件 - bigdecimal / util(LoadError) - rails server throws `require': cannot load such file — bigdecimal/util (LoadError) `require&#39;:无法加载此类文件-rails / all(LoadError) - `require': cannot load such file — rails/all (LoadError) 制作新的Rails应用程序时,出现以下错误:`require&#39;:无法加载此类文件-捆绑程序(LoadError) - When making a new Rails app, I get the following error: `require': cannot load such file — bundler (LoadError) Rails 4,ruby-2.0.0-p247,pow,rvm - LoadError:无法加载这样的文件 - bundler / setup - Rails 4, ruby-2.0.0-p247, pow, rvm - LoadError: cannot load such file — bundler/setup 无法加载此类文件-捆绑程序/安装程序(LoadError)-rails c-于10分钟前工作 - cannot load such file — bundler/setup (LoadError) - rails c - was working 10 minutes ago 无法启动Rails服务器,“没有这样的文件加载 - bundler / setup” - Cannot start Rails Server, “no such file to load — bundler/setup”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM