Bundler %283%29

How To Locally Save A Bundler Gem With Git Source To /vendor/cache

Posted by Weston Ganger on February 03, 2016

Sometimes I have to use a fork of a gem for a bug fix and I have to bundle my gems locally for deployment on a server that isn’t connected to the public internet. This presents a problem because bundler doesn’t locally save gems with git sources but it will save gems with github sources.

Here are the steps to get it to save locally. First add your gem like this in your Gemfile:

# Gemfile
gem 'chosen-rails', github: "westonganger/chosen-rails", branch: :master

Next run bundle install --path vendor/cache

Now change your Gemfile to use the git source so that when you try to bundle install on the server without internet access it wont try to connect.

# Gemfile
gem 'chosen-rails', git: "https://github.com/westonganger/chosen-rails.git", branch: :master

Next run bundle install --path vendor/cache again to update your Gemfile.lock with the changes

Now it will be saved in /vendor/cache and be loaded locally when you bundle install --local on your server.

Related External Links:

Posted in Rails and Tagged with bundler rails ruby gem 

Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts