Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I specify a local gem in my Gemfile?

I'd like Bundler to load a local gem. Is there an option for that? Or do I have to move the gem folder into the .bundle directory?

like image 902
picardo Avatar asked Dec 20 '10 08:12

picardo


People also ask

How do you install gems you added to your Gemfile?

run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.

How do I install a specific version of a gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.

Where is my gem file located?

The Gemfile is wherever you want it to be - usually in the main directory of your project and the name of the file is Gemfile . It's convenient to have one because it allows you to use Bundler to manage which gems and which versions of each your project needs to run.


2 Answers

I believe you can do this:

gem "foo", path: "/path/to/foo" 
like image 109
Jimmy Avatar answered Sep 26 '22 16:09

Jimmy


In addition to specifying the path (as Jimmy mentioned) you can also force Bundler to use a local gem for your environment only by using the following configuration option:

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

This is extremely helpful if you're developing two gems or a gem and a rails app side-by-side.

Note though, that this only works when you're already using git for your dependency, for example:

# In Gemfile gem 'rack', :github => 'rack/rack', :branch => 'master'  # In your terminal $ bundle config local.rack ~/Work/git/rack 

As seen on the docs.

like image 38
bloudermilk Avatar answered Sep 23 '22 16:09

bloudermilk