I came here searching for an answer to a very similar question, but I
ended up with something that's working for me (for now).
I have a locally-developed gem that stands alone, and also serves as
the core of my Rails app. I need my Rails app's bundle to use a
different version of the gem depending on my environment:
development: Check for a local copy. If it's there, use it. If not,
pull from our git repo on the 'develop' branch
test: Pull from our git repo on the 'test' branch
production: Install the deployed gem from our local gem server (which
is listed as a source at the top of the Gemfile)
I haven't worked with it enough to see if it has any implications for
deployment, or if it will wreak havoc with my Gemfile.lock, but here's
what I've done:
my_gem_spec = ">= 1.1.0"
group :development do
if File.directory?("/path/to/local/working/copy") ?
my_gem_spec = { :path => "/path/to/local/working/copy" }
else
my_gem_spec = { :git => "git://local/git/repo/mygem.git", :branch
=> "develop" }
end
end
group :test do
my_gem_spec = { :git => "git://local/git/repo/mygem.git", :branch =>
"test" }
end
gem "my-gem", my_gem_spec
So the 'gem "my-gem"' directive only occurs once, but it gets
different arguments/options depending on the environment. I can then
"bundle install --without='development test'" for production, etc.
It's a bit clunky, but working well so far in my dev and test
environments. I haven't tried a production deployment since setting
this up, but I have no reason to believe it won't work at least
reasonably well.
Michael
On Sep 13, 6:30 pm, Tommy Chheng <
tommy.chh...@gmail.com> wrote:
> I'm trying to include a different version gem depending on the app
> environment group.
>
> When I do:
> gem 'xxxx', :git => '...@github.com:xxxx.git', :tag => 'v0.0.2', :group =>
> [:production]
> gem 'xxxx', :git => '...@github.com:xxxx.git', :group => [:development,