简体   繁体   English

捆绑rvm的软件包

[英]bundle package with rvm

I was reading the book Rails Way. 我在看《 Rails Way》这本书。 And it discusses running "bundle package". 并且讨论了运行“捆绑包”。 This will store all the .gem files your app uses in vendor/cache. 这会将您的应用程序使用的所有.gem文件存储在供应商/缓存中。 Running bundle install will prefer gems in vendor/cache to gems in other locations. 运行软件包安装将首选供应商/缓存中的宝石,而不是其他位置的宝石。 I am using rvm, so I tested this with rvm: 我正在使用rvm,因此我使用rvm对此进行了测试:

rvm gemset create rent_prototype
rvm use 2.2.1@rent_prototype
gem install rails
rvm gemdir
/home/viggy/.rvm/gems/ruby-2.2.1@rentme_prototype
$ cd /home/viggy/.rvm/gems/ruby-2.2.1@rentme_prototype
$ ls -l devise-4.1.1
ls: cannot access devise-4.1.1: No such file or directory

Above I created a gemset with rvm and checked if the devise gem was installed, and it was not since it is not in Gemfile. 上面我用rvm创建了一个gemset,并检查是否安装了devise gem,但这不是因为它不在Gemfile中。 Now I use bundle package: 现在,我使用捆绑包:

$ cd -
$ bundle package

Updating files in vendor/cache
  * rake-11.1.2.gem
  * i18n-0.7.0.gem
  * json-1.8.3.gem
  ...
$ cd vendor/cache
$ ls -l devise-4.1.1
ls: cannot access devise-4.1.1: No such file or directory

Of course, no devise gem in vendor/cache either. 当然,供应商/缓存中也没有任何设计宝石。

Then I modify Gemfile and add: 然后,我修改Gemfile并添加:

gem 'devise'

Then I run bundle install . 然后我运行bundle install

Now I check where devise was installed: 现在,我检查装置的安装位置:

$ bundle show devise
/home/viggy/.rvm/gems/ruby-2.2.1@rentme_prototype/gems/devise-4.1.1
$ cd vendor/cache
$ ls -l devise-4.1.1
ls: cannot access devise-4.1.1: No such file or directory

So when I install a gem, it installs in the rvm folder. 因此,当我安装gem时,它将安装在rvm文件夹中。 It does not prefer vendor/cache to other locations. 与其他位置相比,它不喜欢供应商/缓存。 If that is the case, what is the purpose of "bundle package" when you are using rvm? 如果是这样,那么在使用rvm时“捆绑包”的目的是什么?

As per my comment. 根据我的评论。 You didn't run package after adding devise to your gem file which is why it isn't in vendor/cache. 在将devise添加到gem文件后,您没有运行包,这就是为什么它不在供应商/缓存中。 Bundle install still needs to install the gems on your system. 捆绑安装仍然需要在系统上安装gem。

From bundler website 捆绑器网站

The package command will copy the .gem files for your gems in the bundle into ./vendor/cache. package命令会将捆绑包中的宝石的.gem文件复制到./vendor/cache中。 Afterward, when you run bundle install, Bundler will use the gems in the cache in preference to the ones on rubygems.org. 之后,当您运行捆绑安装时,Bundler将优先使用rubygems.org上的gem。

Additionally, if you then check that directory into your source control repository, others who check out your source will be able to install the bundle without having to download any additional gems. 此外,如果您随后将该目录检入到源代码控制存储库中,那么签出您的源代码的其他人将能够安装捆绑软件,而不必下载任何其他gem。

The rvm gemset and bundler solve some of the same problems with which set of gems/versions are to be used / activated. rvm gemset和bundler解决了与使用/激活宝石/版本集相同的一些问题。 With bundler now you don't need to use rvm gemsets , the gemfile handles it. 现在有了bundler,您不需要使用rvm gemsets,gemfile可以处理它。 But this wasn't always the case. 但这并非总是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM