diff options
author | Bundlerbot <bot@bundler.io> | 2019-04-28 10:37:58 +0000 |
---|---|---|
committer | Bundlerbot <bot@bundler.io> | 2019-04-28 10:37:58 +0000 |
commit | 96b9f632a758cc06abe3c17e8623dfba09e3ee7f (patch) | |
tree | 31eadeb46b03aeed3e9ebe58baee69c436f957b0 | |
parent | 662fe29107bf0dafd55be661a4471f4b7afd73f6 (diff) | |
parent | 8b0779a0719ee702c59e1d638cccc32d9a69767b (diff) | |
download | bundler-96b9f632a758cc06abe3c17e8623dfba09e3ee7f.tar.gz |
Merge #6885
6885: Don't check for the existence of a writable home directory if BUNDLE_USER_HOME is set r=deivid-rodriguez a=jturkel
#6024 added support for specifying an alternate bundler home directory via the `BUNDLE_USER_HOME` environment variable. Unfortunately bundler still checks for a writable user home directory even if the `BUNDLE_USER_HOME` override is specified resulting in warnings like this:
```
`/home/appuser` is not a directory.
Bundler will use `/tmp/bundler/home/unknown' as your home directory temporarily.
```
The fix for this problem is to only evaluate bundler path fallbacks if environment variable overrides are not specified.
Co-authored-by: Joel Turkel <jturkel@salsify.com>
-rw-r--r-- | lib/bundler.rb | 10 | ||||
-rw-r--r-- | spec/bundler/bundler_spec.rb | 1 |
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 0c24a21d7a..8ad5ab6634 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -197,19 +197,19 @@ module Bundler def user_bundle_path(dir = "home") env_var, fallback = case dir when "home" - ["BUNDLE_USER_HOME", Pathname.new(user_home).join(".bundle")] + ["BUNDLE_USER_HOME", proc { Pathname.new(user_home).join(".bundle") }] when "cache" - ["BUNDLE_USER_CACHE", user_bundle_path.join("cache")] + ["BUNDLE_USER_CACHE", proc { user_bundle_path.join("cache") }] when "config" - ["BUNDLE_USER_CONFIG", user_bundle_path.join("config")] + ["BUNDLE_USER_CONFIG", proc { user_bundle_path.join("config") }] when "plugin" - ["BUNDLE_USER_PLUGIN", user_bundle_path.join("plugin")] + ["BUNDLE_USER_PLUGIN", proc { user_bundle_path.join("plugin") }] else raise BundlerError, "Unknown user path requested: #{dir}" end # `fallback` will already be a Pathname, but Pathname.new() is # idempotent so it's OK - Pathname.new(ENV.fetch(env_var, fallback)) + Pathname.new(ENV.fetch(env_var, &fallback)) end def user_cache diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb index e33c8dc606..9b772bffef 100644 --- a/spec/bundler/bundler_spec.rb +++ b/spec/bundler/bundler_spec.rb @@ -457,6 +457,7 @@ MESSAGE it "should use custom home path as root for other paths" do ENV["BUNDLE_USER_HOME"] = bundle_user_home_custom.to_s + allow(Bundler.rubygems).to receive(:user_home).and_raise expect(Bundler.user_bundle_path).to eq(bundle_user_home_custom) expect(Bundler.user_bundle_path("home")).to eq(bundle_user_home_custom) expect(Bundler.user_bundle_path("cache")).to eq(bundle_user_home_custom.join("cache")) |