Using local gems in your Rails application

The Bundler documentation is pretty brief when it comes to creating and using local gems. In a nutshell, if you want to reference a local gem in your application you have […]

The Bundler documentation is pretty brief when it comes to creating and using local gems.

In a nutshell, if you want to reference a local gem in your application you have to make sure a .bundle/config file is created in your application directory (local config) or your home directory (global config). Running the command below will create the .bundle/config file in your application’s directory, provided the current working directory your run the command from is your application’s directory:

bundle config local.GEM_NAME /path/to/local/git/repository

One problem you might run into is that this file gets disregarded when you run “bundle install”.
The solution is fairly simple:
You must specify the gem’s source and branch explicitly in your Gemfile, such that, if you were to include the udemy gem you would setup your Gemfile as follows:

gem 'udemy', git: '[email protected]:jonaphin/udemy.git', branch: "master"

Running bundle install should yield the following message:
Using udemy (0.1.4) from [email protected]:jonaphin/udemy.git (at /local/path/to/udemy)

I hope this helps you as I wish it had helped me 🙂

About jonaphin

Sr. Software Engineer / Project Lead at Adobe Systems, Inc.