diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-09-06 14:22:29 -0400 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-09-07 14:22:08 +0200 |
commit | 02e7f67727b45f59ec0aec4df410e05921d94928 (patch) | |
tree | 37f4a195c9b29e9c6bfdd1a1812ca0f3bf9b048b /lib/bundler | |
parent | 002939bbba581d38ba788016f893a79bca87f855 (diff) | |
download | bundler-02e7f67727b45f59ec0aec4df410e05921d94928.tar.gz |
Fallback to a temp dir when the home directory is not usable
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/cli.rb | 2 | ||||
-rw-r--r-- | lib/bundler/fetcher/compact_index.rb | 2 | ||||
-rw-r--r-- | lib/bundler/gem_helper.rb | 2 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 6 | ||||
-rw-r--r-- | lib/bundler/ui/shell.rb | 4 | ||||
-rw-r--r-- | lib/bundler/ui/silent.rb | 9 |
6 files changed, 21 insertions, 4 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 8b48be35d2..fdfca7f4b7 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -36,8 +36,10 @@ module Bundler ensure self.options ||= {} Bundler.settings.cli_flags_given = !options.empty? + unprinted_warnings = Bundler.ui.unprinted_warnings Bundler.ui = UI::Shell.new(options) Bundler.ui.level = "debug" if options["verbose"] + unprinted_warnings.each {|w| Bundler.ui.warn(w) } if ENV["RUBYGEMS_GEMDEPS"] && !ENV["RUBYGEMS_GEMDEPS"].empty? Bundler.ui.warn( diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb index 9461368df5..63b5c8371d 100644 --- a/lib/bundler/fetcher/compact_index.rb +++ b/lib/bundler/fetcher/compact_index.rb @@ -61,7 +61,7 @@ module Bundler compact_index_request :fetch_spec def available? - user_home = Pathname.new(Bundler.rubygems.user_home) + user_home = Bundler.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! diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index fdb2db7dbf..73cbf9e0d1 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -98,7 +98,7 @@ module Bundler allowed_push_host = @gemspec.metadata["allowed_push_host"] gem_command += " --host #{allowed_push_host}" if allowed_push_host end - unless allowed_push_host || Pathname.new("~/.gem/credentials").expand_path.file? + unless allowed_push_host || Bundler.user_home.join(".gem/credentials").file? raise "Your rubygems.org credentials aren't set. Run `gem push` to set them." end sh(gem_command) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index ca4eafd623..6e95793c03 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -39,10 +39,12 @@ module Bundler bundle_dir = find_directory(".bundle") return nil unless bundle_dir - global_bundle_dir = File.join(Bundler.rubygems.user_home, ".bundle") + bundle_dir = Pathname.new(bundle_dir) + + global_bundle_dir = Bundler.user_home.join(".bundle") return nil if bundle_dir == global_bundle_dir - Pathname.new(bundle_dir) + bundle_dir end def in_bundle? diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb index 5c1fa61568..697290f795 100644 --- a/lib/bundler/ui/shell.rb +++ b/lib/bundler/ui/shell.rb @@ -83,6 +83,10 @@ module Bundler with_level("silent", &blk) end + def unprinted_warnings + [] + end + private # valimism diff --git a/lib/bundler/ui/silent.rb b/lib/bundler/ui/silent.rb index 367eaa58c2..5e0037f488 100644 --- a/lib/bundler/ui/silent.rb +++ b/lib/bundler/ui/silent.rb @@ -2,6 +2,10 @@ module Bundler module UI class Silent + def initialize + @warnings = [] + end + def add_color(string, color) string end @@ -13,6 +17,7 @@ module Bundler end def warn(message, newline = nil) + @warnings |= [message] end def error(message, newline = nil) @@ -44,6 +49,10 @@ module Bundler def silence yield end + + def unprinted_warnings + @warnings + end end end end |