我在尝试创建新的Rails项目时遇到此错误:
/Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:126:in require: cannot load such file -- bundler (LoadError)
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:126:in rescue in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/generators/app_base.rb:319:in bundle_command
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/generators/app_base.rb:335:in run_bundle
from (eval):1:in run_bundle
from /Users/jameslett/.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/jameslett/.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/jameslett/.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/jameslett/.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/jameslett/.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/jameslett/.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/jameslett/.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/jameslett/.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/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands/application.rb:17:in <top (required)>
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:67:in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:67:in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/cli.rb:14:in <top (required)>
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:67:in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:67:in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.2/bin/rails:9:in <top (required)>
from /Users/jameslett/.rbenv/versions/2.2.2/bin/rails:23:in load
from /Users/jameslett/.rbenv/versions/2.2.2/bin/rails:23:in `<main>'
我cd
进入我的项目并运行bundle install
,我收到了此错误:
Errno::EACCES: Permission denied @ rb_sysopen - /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.7.1/.autotest
An error occurred while installing nokogiri (1.6.7.1), and Bundler cannot continue. Make sure that gem install nokogiri -v 1.6.7.1 succeeds before bundling.
如果我运行gem install nokogirl
,我会得到&#34; Errno :: EACCES&#34;再次出错。
我不知道如何解决这个问题。我阅读了Bundler和Nokogirl的文档但是没有帮助。
以防万一,我正在跑步:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
My Gem ENV是:
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-darwin14]
- INSTALLATION DIRECTORY: /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
- USER INSTALLATION DIRECTORY: /Users/jameslett/.gem/ruby/2.2.0
- RUBY EXECUTABLE: /Users/jameslett/.rbenv/versions/2.2.2/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jameslett/.rbenv/versions/2.2.2/bin
- SPEC CACHE DIRECTORY: /Users/jameslett/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/jameslett/.rbenv/versions/2.2.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
- /Users/jameslett/.gem/ruby/2.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
我的宝石路径是否导致此错误?
答案 0 :(得分:2)
你可以试试这个
sudo gem update --system
答案 1 :(得分:2)
确保您拥有.rbenv
文件夹中的所有文件。
$ sudo chown -R $(whoami) /Users/jameslett/.rbenv
此外,所有文件都应该是可读写的。
$ chmod -R u+rw /Users/jameslett/.rbenv
将sudo与实际用户的环境结合使用时,权限可能会混乱。