Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use multiple Gemfiles for my application?

I am working with a team of developers, and we are all using the same Gemfile from our repository. Because I am working on a Mac, and others are using Ubuntu, we have a Gemfile.local.example file in our repository as well that has the appropriate notification gems for each OS, all commented out.

I un-commented the gems for my OS and saved as a new file, not in version control, Gemfile.local. Now I would like "bundle install" to install gems from both files.

I can't find any good documentation on doing this.

like image 498
dudeitsdevin90 Avatar asked Jul 19 '12 16:07

dudeitsdevin90


People also ask

How do I specify a Gemfile version?

There are several ways to specify gem versions: Use a specific version: gem "name-of-gem", "1.0" . You can find specific versions on Rubygems.org (provided that's the source you”re using) by searching for your gem and looking at the “Versions” listed. Use a version operator: gem "name-of-gem", ">1.0" .

What is ~> Gemfile?

A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.

What does bundle exec do?

bundle exec allows us to run an executable script in the specific context of the project's bundle. Upon running the above command, bundle exec will run the executable script for rake version specified in project's Gemfile thus avoiding any conflicts with other versions of rake installed system-wide.


1 Answers

Why not just have one Gemfile and use things like groups or use the :platform flag to only install some gems on OS X and others on Ubuntu?

Seems pretty unwieldy to have two Gemfiles. You can supply the Gemfile to use to bundle config (man page) if you really want to do that, I guess.

like image 71
Edd Morgan Avatar answered Sep 21 '22 22:09

Edd Morgan