diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index 155c80660b1b1..9a33b83c3a46a 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -91,6 +91,9 @@ module EnvConfig description: "Use this as the browser when opening project homepages.", default_text: "`$BROWSER` or the OS's default browser.", }, + HOMEBREW_BUNDLE_USER_CACHE: { + description: "If set, use this directory as the `bundle`(1) user cache.", + }, HOMEBREW_CACHE: { description: "Use this directory as the download cache.", default_text: "macOS: `$HOME/Library/Caches/Homebrew`, " \ diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi index 795c49493b297..ae282cccbec4d 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi @@ -52,6 +52,9 @@ module Homebrew::EnvConfig sig { returns(T.nilable(::String)) } def browser; end + sig { returns(T.nilable(::String)) } + def bundle_user_cache; end + sig { returns(String) } def cache; end diff --git a/Library/Homebrew/utils/gems.rb b/Library/Homebrew/utils/gems.rb index 46ffca2f79a97..6766db8b56cf2 100644 --- a/Library/Homebrew/utils/gems.rb +++ b/Library/Homebrew/utils/gems.rb @@ -224,7 +224,6 @@ def install_bundler_gems!(only_warn_on_failure: false, setup_path: true, groups: old_path = ENV.fetch("PATH", nil) old_gem_path = ENV.fetch("GEM_PATH", nil) old_gem_home = ENV.fetch("GEM_HOME", nil) - old_bundle_user_cache = ENV.fetch("BUNDLE_USER_CACHE", nil) old_bundle_gemfile = ENV.fetch("BUNDLE_GEMFILE", nil) old_bundle_with = ENV.fetch("BUNDLE_WITH", nil) old_bundle_frozen = ENV.fetch("BUNDLE_FROZEN", nil) @@ -244,12 +243,9 @@ def install_bundler_gems!(only_warn_on_failure: false, setup_path: true, groups: groups |= (user_gem_groups & valid_gem_groups) groups.sort! - homebrew_cache = if defined?(HOMEBREW_CACHE) - HOMEBREW_CACHE.to_s - else - ENV.fetch("HOMEBREW_CACHE") + if (homebrew_bundle_user_cache = ENV.fetch("HOMEBREW_BUNDLE_USER_CACHE", nil)) + ENV["BUNDLE_USER_CACHE"] = homebrew_bundle_user_cache end - ENV["BUNDLE_USER_CACHE"] = "#{homebrew_cache}/bundler_cache" ENV["BUNDLE_GEMFILE"] = gemfile ENV["BUNDLE_WITH"] = groups.join(" ") ENV["BUNDLE_FROZEN"] = "true" @@ -346,7 +342,6 @@ def install_bundler_gems!(only_warn_on_failure: false, setup_path: true, groups: ENV["BUNDLE_GEMFILE"] = old_bundle_gemfile ENV["BUNDLE_WITH"] = old_bundle_with ENV["BUNDLE_FROZEN"] = old_bundle_frozen - ENV["BUNDLE_USER_CACHE"] = old_bundle_user_cache end end end diff --git a/bin/brew b/bin/brew index f7b47d0c699c5..e83837ecedc6f 100755 --- a/bin/brew +++ b/bin/brew @@ -144,6 +144,7 @@ MANPAGE_VARS=( BAT_CONFIG_PATH BAT_THEME BROWSER + BUNDLE_USER_CACHE DISPLAY EDITOR NO_COLOR diff --git a/docs/Manpage.md b/docs/Manpage.md index fc62d4e58f1f1..54818ad3f3ddf 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -3568,6 +3568,10 @@ command execution e.g. `$(cat file)`. *Default:* `$BROWSER` or the OS's default browser. +`HOMEBREW_BUNDLE_USER_CACHE` + +: If set, use this directory as the `bundle`(1) user cache. + `HOMEBREW_CACHE` : Use this directory as the download cache. diff --git a/manpages/brew.1 b/manpages/brew.1 index 673a07c724479..b9ba94c5e5faa 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -2295,6 +2295,9 @@ Use this as the browser when opening project homepages\. \fIDefault:\fP \fB$BROWSER\fP or the OS\[u2019]s default browser\. .RE .TP +\fBHOMEBREW_BUNDLE_USER_CACHE\fP +If set, use this directory as the \fBbundle\fP(1) user cache\. +.TP \fBHOMEBREW_CACHE\fP Use this directory as the download cache\. .RS