Method: RightDevelop::Utility::Shell#setup_clean_env

Defined in:
lib/right_develop/utility/shell.rb

#setup_clean_envObject

bundle exec sets GEM_HOME and GEM_PATH (in Windows?) and these need to be wacked in order to have a pristing rubygems environment since bundler won’t clean them. also, if you ‘bundle exec rake …’ and then put arguments to the right of the task name, then these args won’t appear in Bundler::ORIGINAL_ENV. example: “bundle exec rake build:all DEBUG=true …”



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/right_develop/utility/shell.rb', line 49

def setup_clean_env
  # a little revisionist history music...
  ::ENV.each do |key, value|
    if key.start_with?('GEM_') || key.start_with?('BUNDLER_')
      ::Bundler::ORIGINAL_ENV[key] = nil
    elsif Bundler::ORIGINAL_ENV[key].nil?
      ::Bundler::ORIGINAL_ENV[key] = value
    end
  end
  ::Bundler.with_clean_env do
    # now the ENV is clean and not missing any right-hand args so replace
    # the ORIGINAL_ENV.
    ::Bundler::ORIGINAL_ENV.replace(ENV)
  end
  true
end