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

Commit

Permalink
Support read-only git gems (fixes #3092)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmahoney committed Jul 14, 2014
1 parent 0cf6a8b commit ae0de4c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/bundler/source/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ def name
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
Expand Down
8 changes: 8 additions & 0 deletions spec/runtime/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,14 @@
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
Expand Down
14 changes: 14 additions & 0 deletions spec/support/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,5 +344,19 @@ def capture_output
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

0 comments on commit ae0de4c

Please sign in to comment.