我正在运行OS X,10.11.2(15C50),rvm 1.26.11,ruby 2.3.0p0和gem 2.5.1。
如果我尝试运行rails g controller welcome
或任何其他生成命令,我会收到以下错误。
我已经完成了rvm内爆,从头开始安装ruby,rails,bundler。创建了一个新的应用程序,问题仍然存在。
% rails g controller welcome
/Users/username/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/username/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/Projects/tweener-frontend/vendor/bundle/gems/spring-1.6.1/lib/spring/commands.rb:33:in `<module:Spring>'
from /Users/username/Projects/tweener-frontend/vendor/bundle/gems/spring-1.6.1/lib/spring/commands.rb:4:in `<top (required)>'
from /Users/username/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/Projects/tweener-frontend/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:77:in `preload'
from /Users/username/Projects/tweener-frontend/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:143:in `serve'
from /Users/username/Projects/tweener-frontend/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:131:in `block in run'
from /Users/username/Projects/tweener-frontend/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:125:in `loop'
from /Users/username/Projects/tweener-frontend/vendor/bundle/gems/spring-1.6.1/lib/spring/application.rb:125:in `run'
from /Users/username/Projects/tweener-frontend/vendor/bundle/gems/spring-1.6.1/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/username/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
答案 0 :(得分:4)
我遇到了同样的问题,我做了以下事情来解决问题:
bundle install --binstubs
首先尝试,然后尝试运行:
bundle exec rails g controller welcome
希望它有所帮助。
答案 1 :(得分:0)
所以bundle exec rails s
似乎是修复。
我想我需要理解为什么我需要使用bundle exec而不仅仅是rails s
。是时候阅读手册了:))
谢谢大家