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

Commit

Permalink
Don't check for the existence of a writable home directory if BUNDLE_…
Browse files Browse the repository at this point in the history
…USER_HOME is set
  • Loading branch information
jturkel committed Jan 7, 2019
1 parent a63a39d commit 8b0779a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/bundler.rb
Expand Up @@ -198,19 +198,19 @@ def tmp_home_path(login, warning)
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
Expand Down
1 change: 1 addition & 0 deletions spec/bundler/bundler_spec.rb
Expand Up @@ -465,6 +465,7 @@ def clear_cached_requires_sudo

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"))
Expand Down

0 comments on commit 8b0779a

Please sign in to comment.