Referencing local gems in your Gemfile

Posted on: 2012-11-29

If you make your own gems, you'll likely want to try out uncommitted changes within your local projects. Back on Ruby Rogues episode 37, David Brady pointed out that you can use a path: option to tell Bundler to find the gem in your local filesystem.

But that can lead to problems, as he pointed out:

"If you're as absentminded as me, you're going to end up committing the Gemfile. So now everybody is like, 'oh crap, I've got this thing that needs a gem out of `/home/dbrady`, what do I do?'"

We had this problem where I work, too. Some of my coworkers came up with a nice solution using symlinks.

They decided that any local gem paths in the Gemfile must point to /usr/local/gems. In that folder, each person can put a symlink to wherever that project lives on their machine (likely in their home directory).

The fact that usr/local/gems/somegem points to /home/dbrady/my_gems/some_gem on your machine doesn't matter to me at all, because for me it points to Users/nathan/projects/some_gem.