summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-05-06 09:25:24 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-05-06 09:25:24 -0500
commite0845aab59af301fef848089105995d4c964d9f8 (patch)
treeb64def4c9be084f908c338cb5eb55662d37d2445
parentd272105d8f1d614520ca89a9dcc198a34f927e59 (diff)
downloadbundler-seg-compact-index-fallback-no-home.tar.gz
[CompactIndex] Fall back when the user's home directory is not writableseg-compact-index-fallback-no-home
-rw-r--r--lib/bundler/fetcher/compact_index.rb2
-rw-r--r--spec/install/gems/compact_index_spec.rb13
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb
index 3d24a9d728..31557be053 100644
--- a/lib/bundler/fetcher/compact_index.rb
+++ b/lib/bundler/fetcher/compact_index.rb
@@ -59,6 +59,8 @@ module Bundler
compact_index_request :fetch_spec
def available?
+ user_home = Pathname.new(Bundler.rubygems.user_home)
+ return nil unless user_home.directory? && user_home.writable?
# Read info file checksums out of /versions, so we can know if gems are up to date
fetch_uri.scheme != "file" && compact_index_client.update_and_parse_checksums!
rescue CompactIndexClient::Updater::MisMatchedChecksumError => e
diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb
index c00e73523b..ef3bc5aedc 100644
--- a/spec/install/gems/compact_index_spec.rb
+++ b/spec/install/gems/compact_index_spec.rb
@@ -153,6 +153,19 @@ The checksum of /versions does not match the checksum provided by the server! So
should_be_installed "rack 1.0.0"
end
+ it "falls back when the user's home directory does not exist or is not writable" do
+ ENV["HOME"] = nil
+
+ gemfile <<-G
+ source "#{source_uri}"
+ gem "rack"
+ G
+
+ bundle! :install, :artifice => "compact_index"
+ expect(out).to include("Fetching gem metadata from #{source_uri}")
+ should_be_installed "rack 1.0.0"
+ end
+
it "handles host redirects" do
gemfile <<-G
source "#{source_uri}"