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

Commit

Permalink
Merge #7455
Browse files Browse the repository at this point in the history
7455: Lazily load `open3` r=deivid-rodriguez a=deivid-rodriguez

### What was the end-user problem that led to this PR?

The problem was `open3` will be gemified in ruby 2.7, and since we use it inside `bundler`, we might activate a version causing a conflict with the user's choice.

### What was your diagnosis of the problem?

My diagnosis was that only loading it when needed should be better.

### What is your fix for the problem, implemented in this PR?

My fix is to lazily load it.

I expect this PR to fix [some of the errors](https://travis-ci.org/bundler/bundler/jobs/615940817) currently happening in our CI against ruby-head.

Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
(cherry picked from commit 2a5378c)
  • Loading branch information
bundlerbot authored and deivid-rodriguez committed Dec 13, 2019
1 parent a137b11 commit 6d30dcc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/bundler/source/git/git_proxy.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require "open3"
require "shellwords"

module Bundler
Expand Down Expand Up @@ -243,12 +242,14 @@ def allowed_in_path
end

def capture_and_filter_stderr(uri, cmd)
require "open3"
return_value, captured_err, status = Open3.capture3(cmd)
Bundler.ui.warn URICredentialsFilter.credential_filtered_string(captured_err, uri) if uri && !captured_err.empty?
[return_value, status]
end

def capture_and_ignore_stderr(cmd)
require "open3"
return_value, _, status = Open3.capture3(cmd)
[return_value, status]
end
Expand Down
3 changes: 1 addition & 2 deletions spec/support/helpers.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require "open3"

require_relative "command_execution"
require_relative "the_bundle"

Expand Down Expand Up @@ -211,6 +209,7 @@ def sys_exec(cmd, env = {})

env = env.map {|k, v| [k.to_s, v.to_s] }.to_h # convert env keys and values to string

require "open3"
Open3.popen3(env, cmd.to_s) do |stdin, stdout, stderr, wait_thr|
yield stdin, stdout, wait_thr if block_given?
stdin.close
Expand Down

0 comments on commit 6d30dcc

Please sign in to comment.