Rails: How can I specify a local gem with Bundler or in my Gemfile?

You can do the following in your Gemfile, but then you'd have to switch the Gemfile between development and production, which is not recommended:

# Gemfile 
gem "foo", path: "/path/to/foo" 

Alternatively, you can tell Bundler to use a local gem in your current environment. This is preferred as the Gemfile still points to the production version of the gem. Run this in shell:

 bundle config set local.GEM_NAME /path/to/local/git/repository

Note: you have to set the branch of the gem, in Gemfile, for this to work.

You can see if it has worked: cat ./.bundle/config

There is also a user-wide setting that you can manually edit: cat ~/.bundle/config

 

Please login or register to post a comment.