Using Developer Specific Gems on Local Machine

Sometimes developer has different preferences for Gems to be used in Development Enviorment. Some developer may want to user thin as server, some body else may use default webbrick.

We also dont want to do a check everytime if we are committing the Gemfile with our Gems, or it is a Universal Gemset, which every one is using.

Simplest solution is create a new file named Gemfile_Custom. Add this to you main Gemfile as :

Gemfile
1
2
3
4
5
6
7
8
9
10
11
source 'https://rubygems.org'

gem 'rails', '4.0.0'
gem 'mysql2'
...
...
...

if File.exists?('Gemfile_Custom') then
  eval File.read('Gemfile_Custom'), nil, 'Gemfile_Custom'
end    

Last 3 lines are most important. They include the Gems from Gemfile_Custom to your main Gemfile. Now add whichever Gems you want to use to Gemfile_Custom.

Gemfile_Custom
1
2
3
4
5
6
7
source 'https://rubygems.org'


gem 'quiet_assets'
gem 'thin'
gem 'annotate'
gem "foreman", "~> 0.63.0"

Dont’t forget to add Gemfile_Custom to .gitignore. That ways whichever Gem you mention in Gemfile_Custom all are available only to your machine only.

Also, make sure you don’t add any such gem to Gemfile_Custom which is a must required as a dependency to run the application.

Comments