From ea1e881ad9def7432df865392631ac9d55580baf Mon Sep 17 00:00:00 2001 From: Tom Scott Date: Tue, 26 Mar 2013 14:01:14 -0400 Subject: [PATCH 1/2] Ensure Bundler has a clean env before exec_cmd'ing Execute all Git commands in a `Bundler.clean_env` to ensure we're using the right versions of everything. Fixes an issue where previously a `rain` deploy could not be combined with any "Git hook"-creating plugins, such as `git-tracker`, or else the commit would fail due to the improper Ruby being used. Thanks to @stevenharman and @alindeman for showing us this awesome little Bundler trick, which helps us mitigate this issue and any future problems that may be encountered in the course of Rain's use with other Git plugins. --- Gemfile.lock | 2 +- lib/rain/git_tools.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 40d8bdc..147c7bd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,7 @@ PATH specs: rain (1.0.8) capistrano - rails (~> 3.2.8) + rails thor GEM diff --git a/lib/rain/git_tools.rb b/lib/rain/git_tools.rb index 4a14a2a..343394d 100644 --- a/lib/rain/git_tools.rb +++ b/lib/rain/git_tools.rb @@ -85,7 +85,11 @@ def push_tag(tag) # what is/what would have been executed onto stdout. def run_cmd(cmd) puts "executing... #{cmd}" - %x(#{cmd}) unless ENV['RAILS_ENV'] == "test" + Bundler.clean_exec cmd unless testing? + end + + def testing? + ENV['RAILS_ENV'] == "test" end # Full path of the versions.yml file in the Rails app. From 9e3b88437fafe288c94d308b02fabe47e6f0fbfe Mon Sep 17 00:00:00 2001 From: Tom Scott Date: Tue, 26 Mar 2013 14:25:58 -0400 Subject: [PATCH 2/2] clean_exec would not continue running commands after the first one. We're just wrapping the existing execution command in a with_clean_env to mitigate this issue. --- lib/rain/git_tools.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rain/git_tools.rb b/lib/rain/git_tools.rb index 343394d..1b0f03e 100644 --- a/lib/rain/git_tools.rb +++ b/lib/rain/git_tools.rb @@ -85,7 +85,7 @@ def push_tag(tag) # what is/what would have been executed onto stdout. def run_cmd(cmd) puts "executing... #{cmd}" - Bundler.clean_exec cmd unless testing? + Bundler.with_clean_env { %x(#{cmd}) } unless testing? end def testing?