diff options
author | Patrick Mahoney <pat@polycrystal.org> | 2014-07-14 12:52:49 -0500 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2014-07-17 22:37:39 -0700 |
commit | bc40de3f76ca8a1139ca8e07ff842a0226dcdd9d (patch) | |
tree | 35d59a2dcb348d4bd9ecab45e2a8cd8adf387b92 | |
parent | fa9faf2983f0bf21908f6344977f9e163738f63c (diff) | |
download | bundler-bc40de3f76ca8a1139ca8e07ff842a0226dcdd9d.tar.gz |
Support read-only git gems (fixes #3092)
-rw-r--r-- | lib/bundler/source/git.rb | 5 | ||||
-rw-r--r-- | spec/runtime/setup_spec.rb | 8 | ||||
-rw-r--r-- | spec/support/helpers.rb | 14 |
3 files changed, 25 insertions, 2 deletions
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index ee435b8a87..1f720f530b 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -79,11 +79,12 @@ module Bundler def install_path @install_path ||= begin git_scope = "#{base_name}-#{shortref_for_path(revision)}" + path = Bundler.install_path.join(git_scope) - if Bundler.requires_sudo? + if !path.exist? && Bundler.requires_sudo? Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope) else - Bundler.install_path.join(git_scope) + path end end end diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 2d355a325e..4b10cf5780 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -385,6 +385,14 @@ describe "Bundler.setup" do end end end + + it "finds git gem when default bundle path becomes read only" do + bundle "install" + + with_read_only("#{Bundler.bundle_path}/**/*") do + should_be_installed "rack 1.0.0" + end + end end describe "when specifying local override" do diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 9c15783822..db1a785ea2 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -341,5 +341,19 @@ module Spec ensure $stdout = actual_stdout end + + def with_read_only(pattern) + chmod = lambda do |dirmode, filemode| + lambda do |f| + mode = File.directory?(f) ? dirmode : filemode + File.chmod(mode, f) + end + end + + Dir[pattern].each(&chmod[0555, 0444]) + yield + ensure + Dir[pattern].each(&chmod[0755, 0644]) + end end end |