Using local sources in Gemfile
· 1 min read
Letβs imagine we develop application, depending on a couple of our own gems.
Or, say, we decide to break a functionality into several gems. The main
application
Gemfile
thus contains references to our gems among all others.
gem 'mycutegem'
The above uses the gem from Ruby Gems , which is quite inconvenient in our case: we modify it simultaneously. There is option to supply path to load the source locally:
gem 'mycutegem', :path => '../mycutegem'
This is hardly acceptable because
Gemfile
became inconsistent with remote
repository. Unfortunately, we cannot specify rules for different groups
in the
Gemfile
, like:
gem 'mycutegem', :path => '../mycutegem', :group => :development
gem 'mycutegem', '~> 0.9.3', :group => :production
You cannot specify the same gem twice with different version requirements.
The solution is simple. There is an ability to inform bundler about our local copy of repository:
$ bundle config local.mycutegem /home/am/Projects/mycutegem
The latter should be a path to
local
git
repository
. Now the
following code will use our local version of repository (with all the
hot changes,) while all others will use the public source (
:branch
is
mandatory):
gem 'mycutegem',
:git => 'git://github.com/mudasobwa/mycutegem',
:branch => 'master'