Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Memoize Bundler#requires_sudo? (thanks @tmm1)

  • Loading branch information...
commit 47e08d4d04e90b2324cbebf08e7399660142180c 1 parent 3e52bd6
@indirect indirect authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/bundler.rb
View
7 lib/bundler.rb
@@ -191,11 +191,14 @@ def default_lockfile
end
def requires_sudo?
+ return @requires_sudo if @checked_for_sudo
+
path = bundle_path
path = path.parent until path.exist?
- sudo_present = !`which sudo 2>#{NULL}`.empty?
+ sudo_present = !(`which sudo 2>#{NULL}` rescue '').empty?
- settings.allow_sudo? && !File.writable?(path) && sudo_present
+ @checked_for_sudo = true
+ @requires_sudo = settings.allow_sudo? && !File.writable?(path) && sudo_present
end
def mkdir_p(path)
Please sign in to comment.
Something went wrong with that request. Please try again.