summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-05-07 05:05:56 +0900
committerSamuel Giddins <segiddins@segiddins.me>2016-05-06 16:48:41 -0500
commit7d37fc9276cb9c8f10c8f21c7419d836fd185ea4 (patch)
tree4979700f38811b7be3423c7a7983944204b8274a
parentefa7b287a1a9f5bc0f867ecb3908cf5827175bda (diff)
downloadbundler-7d37fc9276cb9c8f10c8f21c7419d836fd185ea4.tar.gz
Auto merge of #4531 - bundler:seg-compact-index-fallback-no-home, r=indirect
[CompactIndex] Fall back when the user's home directory is not writable
-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 81cd11eee0..c893955dfa 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}"