ruby 捆绑器在哪里存储宝石?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11635042/
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 does bundler store gems?
提问by gerky
I know that when using gem install, the gem will be stored under /home/username/.rvm/gems/, under which gemset the gem was installed.
我知道使用时gem install,gem 将存储在 /home/username/.rvm/gems/ 下,gem 安装在该 gemset 下。
But if I use Bundler and specify the gem in the Gemfile, when I run bundle install, where will those gems be stored? And what if I already installed the gem using gem install, if I run bundle install, will it use the previous gem installed using gem install?
但是如果我使用 Bundler 并在 Gemfile 中指定 gem,那么当我运行 bundle install 时,这些 gem 将存储在哪里?如果我已经使用 安装了 gem gem install,如果我运行 bundle install,它会使用以前安装的 gemgem install吗?
采纳答案by Frederick Cheung
It depends. In the usual development setup they are installed where they would be when you install a gem "normally" (by running gem install foo) and bundler won't reinstall gems that are already there. This location depends on how rubygems itself is configured.
这取决于。在通常的开发设置中,它们安装在您“正常”安装 gem(通过运行gem install foo)时的位置,并且 bundler 不会重新安装已经存在的 gem。此位置取决于 rubygems 本身的配置方式。
If you run bundle install with the --deploymentoption then the gems will be installed in a location unique to your app (you can pass this as a separate option but it defaults to vendor/bundle)
如果您使用该--deployment选项运行 bundle install,那么 gems 将安装在您的应用程序独有的位置(您可以将其作为单独的选项传递,但它默认为供应商/捆绑包)
You can also run bundle packageto store all the .gem files your app uses in vendor/cache. Running bundle installwill prefer gems in vendor/cache to gems in other locations.
您还可以运行bundle package以将您的应用程序使用的所有 .gem 文件存储在vendor/cache. bundle install与其他位置的 gem 相比,运行会更喜欢供应商/缓存中的 gem。
回答by James Kingsbery
If you want to find out where a particular gem is stored you can run bundle info <gem-name>. For example:
如果您想找出特定 gem 的存储位置,您可以运行bundle info <gem-name>. 例如:
user@host$ bundle info rake
/var/bundle/ruby/2.1.0/gems/rake-10.4.2
For older versions of rake, the command could be bundle show <gem_name>.
对于旧版本的 rake,命令可以是 bundle show <gem_name>.
回答by Robert Reiz
Here /usr/local/lib/ruby/gems/2.1.0/gems/and here: /usr/local/lib/ruby/gems/2.1.0/bundler/gems/.
这里/usr/local/lib/ruby/gems/2.1.0/gems/和这里:/usr/local/lib/ruby/gems/2.1.0/bundler/gems/。
回答by thisismydesign
Note that gems can also be installed into the bundlefolder within your "Gem Path" (see: bundle env). This happens, for example, with gems installed from git:
请注意,gems 也可以安装到bundle“Gem 路径”中的文件夹中(请参阅:)bundle env。例如,从git以下位置安装 gems 会发生这种情况:
gem 'my-gem', git: "https://github.com/x/y.git"
I assume this is so that custom installations don't conflict with installations from a gem server.
我认为这是为了使自定义安装不会与来自 gem 服务器的安装发生冲突。
回答by bartonstanley
I use bundle config pathto see where gems are stored.
我bundle config path用来查看宝石的存储位置。

