Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Preserve environment when shelling out to gem build
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed May 8, 2019
1 parent 40cfceb commit 3670f66
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/bundler/gem_helper.rb
Expand Up @@ -76,7 +76,7 @@ def install
def build_gem
file_name = nil
gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem"
sh(%W[#{gem} build -V #{spec_path}]) do
sh(%W[#{gem} build -V #{spec_path}], "RUBYOPT" => "-I#{File.expand_path("..", __dir__)}") do
file_name = File.basename(built_gem_path)
SharedHelpers.filesystem_access(File.join(base, "pkg")) {|p| FileUtils.mkdir_p(p) }
FileUtils.mv(built_gem_path, "pkg")
Expand Down Expand Up @@ -180,19 +180,19 @@ def name
gemspec.name
end

def sh(cmd, &block)
out, status = sh_with_status(cmd, &block)
def sh(cmd, env = {}, &block)
out, status = sh_with_status(cmd, env, &block)
unless status.success?
cmd = cmd.shelljoin if cmd.respond_to?(:shelljoin)
raise(out.empty? ? "Running `#{cmd}` failed. Run this command directly for more detailed output." : out)
end
out
end

def sh_with_status(cmd, &block)
def sh_with_status(cmd, env = {}, &block)
Bundler.ui.debug(cmd)
SharedHelpers.chdir(base) do
outbuf = IO.popen(cmd, :err => [:child, :out], &:read)
outbuf = IO.popen(env, cmd, :err => [:child, :out], &:read)
status = $?
block.call(outbuf) if status.success? && block
[outbuf, status]
Expand Down

0 comments on commit 3670f66

Please sign in to comment.