【发布时间】:2016-05-28 05:28:07
【问题描述】:
我正在阅读《Rails Way》一书。它讨论了运行“捆绑包”。这会将您的应用程序使用的所有 .gem 文件存储在供应商/缓存中。运行 bundle install 会更喜欢 vendor/cache 中的 gem,而不是其他位置的 gem。我正在使用 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
上面我用 rvm 创建了一个 gemset 并检查了是否安装了 devise gem,因为它不在 Gemfile 中,所以没有安装。现在我使用捆绑包:
$ 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
当然,供应商/缓存中也没有设计 gem。
然后我修改Gemfile并添加:
gem 'devise'
然后我运行bundle install。
现在我检查设备的安装位置:
$ 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
所以当我安装 gem 时,它会安装在 rvm 文件夹中。它不喜欢供应商/缓存而不是其他位置。如果是这样,那么你在使用rvm时“捆绑包”的目的是什么?
【问题讨论】:
-
您添加设计后没有运行捆绑包。这就是它不在缓存中的原因,您运行了安装。
标签: ruby-on-rails ruby bundle