Skipping native extension recompilation on subsequent bundle install

My production deployments take a few extra minutes due to time it takes to install nokogiri gem (1.6.0). I understand this is because installing the gem triggers native extension compilation.

Note that I have packaged my bundle and checked it into DVCS

bundle package

Is there a way to avoid recompilation of native extensions if nothing else has changed, so that deployments are faster?

Update:

I use Opscode Chef to deploy (chef-solo to be specific)

environment is: Ubuntu 12.04LTS 64bit Ruby 193-p448


I found a way to do this. Here is the explanation:

Bundler, by default installs gems into a folder pointed by the environment variable BUNDLE_PATH . The default value of BUNDLE_PATH is vendor/bundle . Hence all gems are installed in /vendor/bundle folder, which happens to be a private folder (for each version of the Rails application). When a new version of the Rails application is installed, vendor/bundle does not exist. Hence Bundler installs/precompiles each gem. It picks up the gems from vendor/cache which is a good saving over downloading the same from rubygems.org , but it still cannot avoid compilation of native extensions.

We can override this by passing --path /shared/path to the bundle install command line. This will ensure that the gems are always installed in /shared/path , which is accessible to all versions (of the Rails application).

With this approach, bundler will not try to reinstall/recompile a gem, since it finds the same already installed.

so, this is the magic command that worked for me

bundle install --local --deployment --path /shared/bundle --without development test
链接地址: http://www.djcxy.com/p/73868.html

上一篇: jquery html()vs empty()。append()的性能

下一篇: 在后续的bundle安装上跳过本机扩展重新编译