<RubyGems>如何改变宝石环境设置?[英] <RubyGems> How to change gem environment settings?

本文是小编为大家收集整理的关于<RubyGems>如何改变宝石环境设置?的处理方法,想解了<RubyGems>如何改变宝石环境设置?的问题怎么解决?<RubyGems>如何改变宝石环境设置?问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

我安装了rbenv并设置了红宝石和宝石.现在,如果我运行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外,所有人看起来都不错,所有其他人都有自我配置的路径. (所以我真的不希望直接放置在用户主文件夹中的任何与DEV相关的目录.)是否可以灵活地更改这两个env variables,而不会影响ruby,gem和rbenv的正常功能等等?

谢谢!

推荐答案

实际上我在线搜索并找到了解决方案.

只是将以下内容放入您的.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,或简单地重新启动您的终端.现在已经测试了我的env正确.

参考: https://github.com/rubygems/rubygems/rubygems/pull/pull/489

本文地址:https://www.itbaoku.cn/post/786487.html