Read more

How to use a local gem in your Gemfile

Judith Roth
August 02, 2017Software engineer at makandra GmbH

You can use local copies of gems in your Gemfile like this:

gem 'spreewald', :path => '~/gems/spreewald'
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

As soon as you have bundled your project with the local copy of the gem, all code changes in the copy will be available on your project. So you can for example set a debugger or add console output in the gem and use it from your project.
If you checked out the gem with your versioning tool, you can easily reset your changes afterwards or make a pull request for the gem if you improved it.

Don't commit a Gemfile with local paths, because this will not work for other developers.


Another way to use a local gem is to install the gem locally on your system and then override the version from git:

cd ~/gems/spreewald
rvm use 2.5.1 # or rbenv local 2.5.1 # use the ruby version your project, which should use the gem, uses
rake install 

If you want to switch back to use the version from Rubygems use gem uninstall spreewald to uninstall the local version and gem install spreewald to reinstall from Rubygems.

Posted by Judith Roth to makandra dev (2017-08-02 09:47)