Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to use a local Ruby gem in Rails project?


You are working on a Rails app that uses a gem named abc. This gem is hosted on RubyGems and the source code of the gem is available at

You created a new branch locally for your gem (new-feature). You wanted to modify the gem and load it directly to your local Rails app. And, you don't want to push the gem changes to GitHub and publish the gem to RubyGems just yet.

You want all the changes that you made in your local gem directory get reflected immediately in your local Rails app without requiring you to run gem build and gem install command in the gem's local directory.


  1. Update Rails app's Gemfile:

    - gem "abc"
    + gem "abc", github: "your-username/abc", branch: "new-feature"
  2. Run bundle config command:

    $ cd /path/to/rails/app
    $ bundle config --local /full/path/to/local/abc/gem
  3. Confirm the bundle config:

    $ bundle config
    Settings are listed in order of priority. The top value will be used.
    Set for your local app (/Users/username/path-to-rails-app/.bundle/config): "/full/path/to/local/abc/gem"
  4. Bundle

    $ bundle install

    You will something like Using abc 1.4.4 from (at /full/path/to/local/abc/gem@git-hash) from the bundle outputs.

Done. Now you can modify the abc gem in the /full/path/to/local/abc/gem directory and it will get reflected in your Rails app.


When you don't need that local path anymore, simply run:

$ bundle config --delete local.YOUR_GEM_NAME

And, revert your Rails app's Gemfile:

- gem "abc", github: "your-username/abc", branch: "new-feature"
+ gem "abc"

Followed by bundle install command (if needed).


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment