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 https://github.com/your-username/abc.
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.
-
Update Rails app's Gemfile:
- gem "abc" + gem "abc", github: "your-username/abc", branch: "new-feature"
-
Run
bundle configcommand:$ cd /path/to/rails/app $ bundle config --local local.abc /full/path/to/local/abc/gem -
Confirm the
bundle config:$ bundle config Settings are listed in order of priority. The top value will be used. local.abc Set for your local app (/Users/username/path-to-rails-app/.bundle/config): "/full/path/to/local/abc/gem" -
Bundle
$ bundle installYou will something like
Using abc 1.4.4 from https://github.com/your-username/abc.git (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).