From ef2291e6075a61cccc7718fcc1b755cbdae7c499 Mon Sep 17 00:00:00 2001 From: Eimhin Laverty Date: Mon, 12 Nov 2018 14:59:25 +0000 Subject: [PATCH] (MODULES-8002) - Fix bundle commands not running in correct dir --- lib/pdksync.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/pdksync.rb b/lib/pdksync.rb index 62075c3b..58a935a1 100755 --- a/lib/pdksync.rb +++ b/lib/pdksync.rb @@ -9,6 +9,7 @@ require 'json' require 'yaml' require 'colorize' +require 'bundler' # @summary # This module set's out and controls the pdksync process @@ -263,8 +264,21 @@ def self.clone_directory(namespace, module_name, output_path) # @return [Integer] # The status code of the command run. def self.run_command(output_path, command) + stdout = '' + stderr = '' + status = Process::Status + Dir.chdir(output_path) unless Dir.pwd == output_path - stdout, stderr, status = Open3.capture3(command) + + # Environment cleanup required due to Ruby subshells using current Bundler environment + if command =~ %r{^bundle} + Bundler.with_clean_env do + stdout, stderr, status = Open3.capture3(command) + end + else + stdout, stderr, status = Open3.capture3(command) + end + puts "\n#{stdout}\n".yellow puts "(FAILURE) Unable to run command '#{command}': #{stderr}".red unless status.exitstatus.zero? status.exitstatus