Hello 👋 Welcome to my corner of the internet. I write here about the different challenges I encounter, and the projects I work on. Find out more about me.
Recently I had to fork and adjust a gem. To test whether the integration of this gem within my own project that I was working on was fine, I was looking for a way to use the gem locally, so that I did not have to push it to github or rubygems. Turns out, there is a perfectly easy way to achieve that:
What you do is, you refer to the gem in your Gemfile the regular way, for example:
# Gemfile
source 'https://rubygems.org'
gem 'my-beautiful-gem', '>= 1.0.0'
Then, in your terminal, you assign the gem locally like so:
bundle config local.my-beautiful-gem /Users/glennjones/projects/rubygems/my-beautiful-gem
This ensures that when you bundle, your local gem is referred and loaded. If you then want to reload the gem in your console, you can:
load "/Users/glennjones/projects/rubygems/my-beatiful-gem/lib/my-beautiful-gem/some_class.rb"
When you’re done, you can disable bundler to use the local gem like so:
bundle config --delete local.my-beautiful-gem