I remember I used gem install rails
to install Rails, but today when I want to install another gem, by typing
gem install ruby-recaptcha
it fails, saying:
You don't have write permissions into the ...
Then I found my gem environment
and sudo gem environment
have different results:
For gem environment
:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin11.0.1]
- INSTALLATION DIRECTORY: /Users/hx/.rvm/gems/ruby-1.9.2-p290
- RUBY EXECUTABLE: /Users/hx/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
- EXECUTABLE DIRECTORY: /Users/hx/.rvm/gems/ruby-1.9.2-p290/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Users/hx/.rvm/gems/ruby-1.9.2-p290
- /Users/hx/.rvm/gems/ruby-1.9.2-p290@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :gempath => ["/Users/hx/.rvm/gems/ruby-1.9.2-p290"]
- :sources => ["http://rubygems.org/"]
- REMOTE SOURCES:
- http://rubygems.org/
For sudo gem environment
:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin11.0.1]
- INSTALLATION DIRECTORY: /Users/hx/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/hx/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
- EXECUTABLE DIRECTORY: /Users/hx/.rvm/rubies/ruby-1.9.2-p290/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Users/hx/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1
- /Users/hx/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :gempath => ["/Users/hx/.rvm/gems/ruby-1.9.2-p290"]
- :sources => ["http://rubygems.org/"]
- REMOTE SOURCES:
- http://rubygems.org/
Noticed that the installation directory is different. So when I use gem
, I do not have permissions (I don't know why I suddenly lose the permission). But when I use sudo gem
, the gem is not installed into the right place. How can I fix this?