Ruby-on-rails 宝石安装在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3408868/
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
Where do gems install?
提问by Trip
I'm trying to edit one of the gem's config files and I can't find it. I'm not sure how I did this in the past.
我正在尝试编辑 gem 的配置文件之一,但找不到它。我不确定我过去是如何做到这一点的。
回答by theIV
Look at your gem environment.
看看你的 gem 环境。
In a terminal run gem env
在终端运行中 gem env
You should see an entry INSTALLATION DIRECTORY, but there is also GEM PATHSwhich is where it's loading all your gems from in your current environment.
您应该会看到一个 entry INSTALLATION DIRECTORY,但还有一个条目GEM PATHS是它从当前环境中加载所有 gem 的位置。
回答by drinor
Rvm
虚拟机
$ rvm gemdir
Or you can check:
或者您可以检查:
echo $GEM_HOME
Bundler
捆绑器
$ bundle show --paths
For specific gem:
对于特定的宝石:
$ bundle show 'gem_name'
Gem
宝石
$ gem env
For specific gem:
对于特定的宝石:
$ gem which 'gem_name'
回答by Bian Jiaping
To see the default installation directory, run
要查看默认安装目录,请运行
gem env gemdir
gem env gemdir
If you want to change the default installation directory (for example, to ~/.gem/ruby/2.1.0), add this line to ~/.bashrc
如果要更改默认安装目录(例如,更改为 ~/.gem/ruby/2.1.0),请将此行添加到 ~/.bashrc
export GEM_HOME=~/.gem/ruby/2.1.0
export GEM_HOME=~/.gem/ruby/2.1.0
And you also need to make sure ~/.gem/ruby/2.1.0/bin is in your PATH environment variable to use the commands provided by gem packages. If not, add this line to ~/.bashrc
并且您还需要确保 ~/.gem/ruby/2.1.0/bin 在您的 PATH 环境变量中才能使用 gem 包提供的命令。如果没有,将此行添加到 ~/.bashrc
export PATH=$PATH:~/.gem/ruby/2.1.0/bin
export PATH=$PATH:~/.gem/ruby/2.1.0/bin
回答by kikito
If you are editing the gem's installed files, then the gem wasn't implemented correctly, or you are not modifying it correctly.
如果您正在编辑 gem 的已安装文件,则表示该 gem 没有正确实现,或者您没有正确修改它。
Proper gems are usually configured:
通常配置合适的 gems:
- via an initializer script on
config/initializers - via monkeypatching on
lib - via generators provided by the gem itself. These tend to generate lots of files, but they usually have a "initialize" or "install" option for setting up the gem.
- 通过初始化脚本
config/initializers - 通过猴子补丁
lib - 通过 gem 本身提供的生成器。这些往往会生成大量文件,但它们通常具有用于设置 gem 的“初始化”或“安装”选项。

