diff options
author | Bundlerbot <bot@bundler.io> | 2019-12-12 12:09:52 +0000 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-12-13 20:07:21 +0100 |
commit | 4e5e9cd49b16f136482505de6a3258aabdb26a99 (patch) | |
tree | b0b691eb55d624f1d714b9eaed8a6e2265e8c82e /lib | |
parent | cd3fb55c06b18673f2cfbb946d6fc81375afa3ea (diff) | |
download | bundler-4e5e9cd49b16f136482505de6a3258aabdb26a99.tar.gz |
Merge #7474
7474: Fix `bundle exec rake install` failing r=deivid-rodriguez a=deivid-rodriguez
### What was the end-user problem that led to this PR?
The problem was that I noticed `bundle exec rake install` was failing on my gem using the latest prerelease of bundler.
### What was your diagnosis of the problem?
My diagnosis was that `bundler` silences output of rubygems by default, and in a `bundle exec` context, `bundler/setup` is always required by subprocesses. So, the `rake install` task is silencing rubygems, but it requires it to not be silent:
https://github.com/bundler/bundler/blob/bada03dd6d4d15828fb5b2cf7f744948e88a69a3/lib/bundler/gem_helper.rb#L91-L92
### What is your fix for the problem, implemented in this PR?
My fix is to wrap the execution of the rubygems subprocess with `Bundler.with_original_env` so that the `gem` command runs without `bundler` involved.
Co-authored-by: David RodrÃguez <deivid.rodriguez@riseup.net>
(cherry picked from commit f44ebf017001239a3e66589dff5aa77f631ca6e2)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/gem_helper.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index 46a6643233..7d4e382be8 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -73,8 +73,7 @@ module Bundler def build_gem file_name = nil - gem = ENV["GEM_COMMAND"] ? ENV["GEM_COMMAND"] : "gem" - sh("#{gem} build -V #{spec_path}".shellsplit) do + sh("#{gem_command} build -V #{spec_path}".shellsplit) 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") @@ -85,11 +84,10 @@ module Bundler def install_gem(built_gem_path = nil, local = false) built_gem_path ||= build_gem - gem = ENV["GEM_COMMAND"] ? ENV["GEM_COMMAND"] : "gem" - cmd = "#{gem} install #{built_gem_path}" + cmd = "#{gem_command} install #{built_gem_path}" cmd += " --local" if local - out, status = sh_with_status(cmd.shellsplit) - unless status.success? && out[/Successfully installed/] + _, status = sh_with_status(cmd.shellsplit) + unless status.success? raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" end Bundler.ui.confirm "#{name} (#{version}) installed." @@ -98,13 +96,13 @@ module Bundler protected def rubygem_push(path) - gem_command = %W[gem push #{path}] - gem_command << "--key" << gem_key if gem_key - gem_command << "--host" << allowed_push_host if allowed_push_host + cmd = %W[#{gem_command} push #{path}] + cmd << "--key" << gem_key if gem_key + cmd << "--host" << allowed_push_host if allowed_push_host unless allowed_push_host || Bundler.user_home.join(".gem/credentials").file? raise "Your rubygems.org credentials aren't set. Run `gem push` to set them." end - sh_with_input(gem_command) + sh_with_input(cmd) Bundler.ui.confirm "Pushed #{name} #{version} to #{gem_push_host}" end @@ -211,5 +209,9 @@ module Bundler def gem_push? !%w[n no nil false off 0].include?(ENV["gem_push"].to_s.downcase) end + + def gem_command + ENV["GEM_COMMAND"] ? ENV["GEM_COMMAND"] : "gem" + end end end |