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

Don't check for the existence of a writable home directory if BUNDLE_USER_HOME is set #6885

Merged
1 commit merged into from Apr 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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