Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Search $PATH for a binary rather than shelling out to `which`

  • Loading branch information...
commit d3a69d32af97bf7c9d04eb2d258d152f102e9910 1 parent d1bed41
@tenderlove tenderlove authored
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/bundler.rb
13 lib/bundler.rb
@@ -229,7 +229,7 @@ def requires_sudo?
path = bundle_path
path = path.parent until path.exist?
- sudo_present = !(`which sudo` rescue '').empty?
+ sudo_present = which "sudo"
bin_dir =
bin_dir = bin_dir.parent until bin_dir.exist?
@@ -246,6 +246,17 @@ def mkdir_p(path)
+ def which(binary)
+ if File.executable? binary
+ binary
+ else
+ path = ENV['PATH'].split(File::PATH_SEPARATOR).find { |path|
bfolkens added a note

ENV['PATH'] is sometimes nil and breaks in a production environment I have with Passenger... Can we change it to ENV['PATH'].to_s or something to avoid that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ File.executable? File.join(path, binary)
+ }
+ path && File.expand_path(binary, path)
+ end
+ end
def sudo(str)
`sudo -p 'Enter your password to install the bundled RubyGems to your system: ' #{str}`
Please sign in to comment.
Something went wrong with that request. Please try again.