我安装了rbenv
并设置了ruby和gem。现在,如果我运行gem env
,那么我得到以下内容:
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin13.0]
- INSTALLATION DIRECTORY: /Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /Users/myusername/Tools/.rbenv/versions/2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/myusername/Tools/.rbenv/versions/2.1.0/bin
- SPEC CACHE DIRECTORY: /Users/myusername/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-13
- GEM PATHS:
- /Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- /Users/myusername/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/myusername/Tools/.rbenv/versions/2.1.0/bin
- /Users/myusername/Tools/.rbenv/libexec
- /Users/myusername/Tools/.rbenv/plugins/ruby-build/bin
- /opt/local/bin
- /opt/local/sbin
- /Users/myusername/Tools/.rbenv/shims
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/bin
- /Users/myusername/Tools/./bin
- /Users/myusername/Tools/.rbenv/bin
嗯..除了SPEC CACHE DIRECTORY
和GEM PATHS
之外,所有其他人都有自我配置的路径。 (所以我真的不希望任何与开发相关的目录直接放在我的用户主文件夹中。)有没有办法灵活地改变这两个env variables
而不影响ruby
的正常运作,{ {1}}和gem
等?
谢谢!
答案 0 :(得分:16)
实际上我在线搜索并找到了解决方案。
只需将以下内容放入.profile(Max OS)或.bashrc(Linux)
即可export GEM_PATH=/Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
export GEM_SPEC_CACHE=/Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/specs
确保您放置的文件夹存在。然后获取.profile或.bashrc,或者只是重新启动终端。它已经过测试,现在我的环境是正确的。