ruby GEM_HOME 和 GEM_PATH 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11277227/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 05:15:08  来源:igfitidea点击:

What's the difference between GEM_HOME and GEM_PATH?

rubyrubygems

提问by Michiel de Mare

RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a "gem"), a tool designed to easily manage the installation of gems, and a server for distributing them. It is analogous to EasyInstall for the Python programming language. RubyGems is now part of the standard library from Ruby version 1.9.

RubyGems 是 Ruby 编程语言的包管理器,它提供了用于分发 Ruby 程序和库的标准格式(以称为“gem”的自包含格式)、旨在轻松管理 gems 安装的工具以及用于分发它们。它类似于 Python 编程语言的 EasyInstall。RubyGems 现在是 Ruby 1.9 版标准库的一部分。

That said, what's the difference between GEM_HOME and GEM_PATH?

也就是说, GEM_HOME 和 GEM_PATH 之间有什么区别?

回答by Michiel de Mare

GEM_PATH provides the locations (there may be several) where gems can be found.

GEM_PATH 提供了可以找到宝石的位置(可能有几个)。

GEM_HOME is where gems will be installed (by default).

GEM_HOME 是安装 gem 的地方(默认情况下)。

(Therefore GEM_PATH should include GEM_HOME).

(因此 GEM_PATH 应该包括 GEM_HOME)。

回答by Green

Also interesting notice. At least on Wndows XP, don't know about other platforms.

还有有趣的通知。至少在 Wndows XP 上,不知道其他平台。

Set GEM_HOMEin Windows:

GEM_HOME在 Windows 中设置:

C:\>set GEM_HOME=C:\sbox\ruby\dump\.gems

Now let's check this.

现在让我们检查一下。

1) In Windows ENVs. All OK, as expected:

1) 在 Windows 环境中。一切正常,正如预期的那样:

C:\>set
...
GEM_HOME=C:\sbox\ruby\dump\.gems
...

2) With gem env. Notice it puts GEM_HOMEalong with GEM_PATHs but at the first place:

2) 与gem env。请注意,它GEM_HOMEGEM_PATHs放在一起,但首先是:

C:\>gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 2.0.0 (2013-02-24 patchlevel 0) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/sbox/ruby/dump/.gems
  - RUBY EXECUTABLE: C:/Ruby200/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/sbox/ruby/dump/.gems/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/sbox/ruby/dump/.gems
     - C:/Documents and Settings/User/.gem/ruby/2.0.0
     - C:/Ruby200/lib/ruby/gems/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

3) Now with bundle env:

3)现在bundle env

C:\>bundle env
Bundler 1.3.4
Ruby 2.0.0 (2013-02-24 patchlevel 0) [i386-mingw32]
Rubygems 2.0.3
GEM_HOME C:\sbox\ruby\dump\.gems
GEM_PATH

GEM_PATHis empty, it means default value. But from where does it take the default value? See gem env.

GEM_PATH为空,表示默认值。但是它从哪里取默认值呢?见gem env