Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

require_sudo when Gem.bindir isn't writeable

  • Loading branch information...
commit d3291eefeffee234dcfb45016d6572bc5e1d91c3 1 parent f09d3c1
@hone hone authored
Showing with 16 additions and 1 deletion.
  1. +4 −1 lib/bundler.rb
  2. +12 −0 spec/install/gems/dependency_api_spec.rb
View
5 lib/bundler.rb
@@ -223,9 +223,12 @@ def requires_sudo?
path = bundle_path
path = path.parent until path.exist?
sudo_present = !(`which sudo` rescue '').empty?
+ bin_dir = Pathname.new(Bundler.rubygems.gem_bindir)
+ bin_dir = bin_dir.parent until bin_dir.exist?
@checked_for_sudo = true
- @requires_sudo = settings.allow_sudo? && !File.writable?(path) && sudo_present
+ can_write_gems = !File.writable?(path) || !File.writable?(bin_dir)
+ @requires_sudo = settings.allow_sudo? && can_write_gems && sudo_present
end
def mkdir_p(path)
View
12 spec/install/gems/dependency_api_spec.rb
@@ -226,4 +226,16 @@
bundle :install, :artifice => "endpoint_api_missing"
should_be_installed "foo 1.0"
end
+
+ it "should install when EndpointSpecification with a bin dir owned by root", :sudo => true do
+ sys_exec "mkdir -p #{system_gem_path("bin")}"
+ sudo "chown -R root #{system_gem_path("bin")}"
+
+ gemfile <<-G
+ source "#{source_uri}"
+ gem "rails"
+ G
+ bundle :install, :artifice => "endpoint"
+ should_be_installed "rails 2.3.2"
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.