From 1d00504a8f11fc64abb7d3310aafb6afc97bd140 Mon Sep 17 00:00:00 2001 From: Chris Oliver Date: Fri, 20 Nov 2020 11:38:55 -0600 Subject: [PATCH 1/3] Use bundler original env when running bundle commands. Fixes #173 --- lib/appraisal/command.rb | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/lib/appraisal/command.rb b/lib/appraisal/command.rb index 26619e50..d2dcba5a 100644 --- a/lib/appraisal/command.rb +++ b/lib/appraisal/command.rb @@ -3,22 +3,21 @@ module Appraisal # Executes commands with a clean environment class Command - BUNDLER_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE).freeze - - attr_reader :command, :env, :gemfile, :original_env + attr_reader :command, :env, :gemfile def initialize(command, options = {}) @gemfile = options[:gemfile] @env = options.fetch(:env, {}) @command = command_starting_with_bundle(command) - @original_env = {} end def run - with_clean_env { ensure_bundler_is_available } - announce + Bundler.with_original_env do + ensure_bundler_is_available + announce - with_clean_env do + ENV['BUNDLE_GEMFILE'] = gemfile + ENV['APPRAISAL_INITIALIZED'] = '1' env.each_pair do |key, value| ENV[key] = value end @@ -31,15 +30,6 @@ def run private - def with_clean_env - unset_bundler_env_vars - ENV['BUNDLE_GEMFILE'] = gemfile - ENV['APPRAISAL_INITIALIZED'] = '1' - yield - ensure - restore_env - end - def ensure_bundler_is_available version = Utils.bundler_version unless system %(gem list -i bundler -v #{version}) @@ -66,17 +56,6 @@ def announce end end - def unset_bundler_env_vars - BUNDLER_ENV_VARS.each do |key| - original_env[key] = ENV[key] - ENV[key] = nil - end - end - - def restore_env - original_env.each { |key, value| ENV[key] = value } - end - def command_starts_with_bundle?(original_command) if original_command.is_a?(Array) original_command.first =~ /^bundle/ From 8bb003b273ae074356dc67b59ecc67c8ae2f3a27 Mon Sep 17 00:00:00 2001 From: Chris Oliver Date: Sat, 21 Nov 2020 11:29:21 -0600 Subject: [PATCH 2/3] Please hound --- lib/appraisal/command.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/appraisal/command.rb b/lib/appraisal/command.rb index d2dcba5a..387b87d7 100644 --- a/lib/appraisal/command.rb +++ b/lib/appraisal/command.rb @@ -16,8 +16,8 @@ def run ensure_bundler_is_available announce - ENV['BUNDLE_GEMFILE'] = gemfile - ENV['APPRAISAL_INITIALIZED'] = '1' + ENV["BUNDLE_GEMFILE"] = gemfile + ENV["APPRAISAL_INITIALIZED"] = "1" env.each_pair do |key, value| ENV[key] = value end From 975180ee86f5e79e4ff1cdb97d86673c62c72a6d Mon Sep 17 00:00:00 2001 From: Ben Sheldon Date: Tue, 20 Jul 2021 07:06:28 -0700 Subject: [PATCH 3/3] Explicit require for Set --- lib/appraisal/dependency_list.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/appraisal/dependency_list.rb b/lib/appraisal/dependency_list.rb index 090da988..cfdf36ea 100644 --- a/lib/appraisal/dependency_list.rb +++ b/lib/appraisal/dependency_list.rb @@ -1,4 +1,5 @@ require 'appraisal/dependency' +require "set" module Appraisal class DependencyList