Know what errors lurk in your code? Rollbar detects and alerts you when code breaks in production. Get the stack trace, code, and data to help you d̶e̶b̶u̶g̶ defeat Ruby errors. Learn more.

RubyFlow The Ruby and Rails community linklog


The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Referencing local gems in your Gemfile

If you need to reference local gems in your Gemfile, but don’t want to annoy your coworkers by hardcoding a path in your home directory, here’s a quick solution.


You can use paths that are relative the the Gemfile - i.e. :path => “../gemname”

Good point. But that still might mean making an assumption based on your own directory structure that isn’t true for your teammates.

You still have the problem of having to remove local paths when you are ready to deploy. Or is there some other way around that?

@trans - you’re right. I don’t know a way around that. What we do is comment out the line pointing to the local gem and uncomment the one pointing to the the git repo.

A solution to the commenting/uncommenting problem is to define method and configure it using environment variables from the command line, something like this:

def local_gem(name) if ENV[“GEM_#{name.uppercase}”] == “local” gem name else gem name, :path => “/usr/local/gems/#{name}” end end

Then you could:

GEM_DEVISE=local rails server

Just don’t forget to do a plain bundle install before committing.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in