Glenn Jones

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.

Refer to a local gem within a ruby project

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 ''

gem 'my-beautiful-gem', '>= 1.0.0'

Then, in your terminal, you assign the gem locally like so:

bundle config /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


Previous: Fixing gdal-bin error cannot open shared object file no such file or directory
Next: Fixing 'no such middleware to insert before: actiondispatch::static' when precompiling rails assets during docker build