新Rails应用程序和捆绑安装执行错误

时间:2015-11-27 17:09:13

标签: ruby-on-rails ruby bundler rbenv

我正在创建新的应用程序,作为最后一步,它运行bundle install命令,该命令失败:

run  bundle install /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require': cannot load such file -- bundler (LoadError)  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'   
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/app_base.rb:330:in `bundle_command'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/app_base.rb:346:in `run_bundle'  
from (eval):1:in `run_bundle'   
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'   
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'   
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'   
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/application.rb:17:in `<top (required)>'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/cli.rb:14:in `<top (required)>'   
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'  
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.5/bin/rails:9:in `<top (required)>'   
from /Users/khataev/.rbenv/versions/2.2.2/bin/rails:23:in `load'  
from /Users/khataev/.rbenv/versions/2.2.2/bin/rails:23:in `<main>'

为什么会失败?我安装了bundler,但如果我尝试从运行rails new命令的目录运行它,则会出错:

khataev@~/Documents/development/rails$ bundle install
Could not locate Gemfile or .bundle/ directory

但在项目目录中它工作正常。也许这就是原因?

1 个答案:

答案 0 :(得分:0)

我不确定我是否理解你的问题。所以你在一个目录中运行,例如&#34; rails new test&#34;。这将创建一个名为&#34; test&#34;的新项目文件夹。您只能在&#34; test&#34;内部运行bundle命令。文件夹,因为那是包含gemfile的文件,告诉bundler要安装什么gems。