如何更改 ruby gem 文件夹在 linux 中的位置

How to change to the location of ruby gem folder in linux

在 Linux 中,我家有文件夹 ~/.gems。我想将其移动到 /opt/Ruby

我该怎么做?

GEM_HOME 环境变量设置为您希望安装 gem 的位置(例如 /opt/Ruby),然后将所有现有的移动到那里。

如果您使用的是 Linux/UNIX,您需要在 .profile 或类似内容中更新 GEM_HOME。

我不会同时调整 GEM_HOMEGEM_PATH,而是生成一个符号 link:

ln -s /opt/Ruby ~/.gems

这样一来,所有内容都位于 /opt 下,而 system/ruby/anything 会在默认位置下找到宝石。