从rvm迁移到rbenv后,gem注释无法正常工作

时间:2014-08-29 01:17:27

标签: ruby-on-rails ruby

我可以通过执行sudo gem install annotate来安装注释(由于权限被拒绝,我不得不使用sudo)。它似乎已安装但运行时出错。我认为这个问题可能与卸载rvm有关。 (现在使用rbenv)。当我安装rvm时,我删除了〜/ .rvm文件夹并删除了.bash_profile中的引用

无法以常规用户身份安装注释

Chris-Muenchs-MacBook-Air:wifiwaiters cmuench$ gem install annotate
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_sysopen - /Users/cmuench/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/annotate-2.6.5/AUTHORS.rdoc
Chris-Muenchs-MacBook-Air:wifiwaiters cmuench$ 

能够通过sudo安装

Chris-Muenchs-MacBook-Air:wifiwaiters cmuench$ sudo gem install annotate
Successfully installed annotate-2.6.5
Parsing documentation for annotate-2.6.5
Done installing documentation for annotate after 0 seconds
1 gem installed

SUDO

Chris-Muenchs-MacBook-Air:wifiwaiters cmuench$ sudo annotate
/Users/cmuench/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'annotate' (>= 0) among 54 total gem(s) (Gem::LoadError)
    from /Users/cmuench/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'
    from /Users/cmuench/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
    from /Users/cmuench/.rbenv/versions/2.1.2/bin/annotate:22:in `<main>'

NON SUDO

Chris-Muenchs-MacBook-Air:wifiwaiters cmuench$ annotate
/Users/cmuench/Desktop/WifiWaiters-Repos/wifiwaiters/Gemfile:24:in `evaluate': compile error (SyntaxError)
/Users/cmuench/Desktop/WifiWaiters-Repos/wifiwaiters/Gemfile:24: syntax error, unexpected ':', expecting $end
gem 'sdoc', '~> 0.4.0',          group: :doc
                                       ^
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/definition.rb:17:in `build'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:136:in `definition'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:124:in `load'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:107:in `setup'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/setup.rb:6
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /Users/cmuench/Desktop/WifiWaiters-Repos/wifiwaiters/config/boot.rb:4
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /Users/cmuench/Desktop/WifiWaiters-Repos/wifiwaiters/config/application.rb:1
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from ./Rakefile:4
    from /Library/Ruby/Gems/1.8/gems/annotate-2.4.0/lib/annotate.rb:17:in `load'
    from /Library/Ruby/Gems/1.8/gems/annotate-2.4.0/lib/annotate.rb:17:in `load_tasks'
    from /Library/Ruby/Gems/1.8/gems/annotate-2.4.0/bin/annotate:66
    from /usr/bin/annotate:19:in `load'
    from /usr/bin/annotate:19
Chris-Muenchs-MacBook-Air:wifiwaiters cmuench$ 

1 个答案:

答案 0 :(得分:0)

通过执行修复:

sudo chmod -R 755 ~/.rbenv

现在我不需要使用sudo来安装gems并运行它们