Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env_config: add HOMEBREW_BUNDLE_USER_CACHE. #17327

Merged
merged 1 commit into from
May 17, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we default to a location inside HOMEBREW_CACHE? Otherwise we would write to HOME, which is weird.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the request, asking for a HOMEBREW_CACHE default is just asking for this PR to be closed and keep #17324 functionality?

I don't think we should have or need a default at all. The existing logic was fine for everyone except dkav.

Alternatively: we rip out all this logic and make #17276 a WONTFIX. Really not convinced this is worth the amount of effort that's gone into it and definitely not worth any more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the request, asking for a HOMEBREW_CACHE default is just asking for this PR to be closed and keep #17324 functionality?

Not necessarily; we can simply add a default: key here. Will make an in-line suggestion below.

I don't think we should have or need a default at all. The existing logic was fine for everyone except dkav.

Ok, that's fine! I just agreed with you when you said not writing to HOME would be ideal. But I'm not hugely bothered by it, so we can leave this as it is.

Copy link
Member

@carlocab carlocab May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "If set, use this directory as the `bundle`(1) user cache.",
description: "If set, use this directory as the `bundle`(1) user cache.",
default: "#{HOMEBREW_DEFAULT_CACHE}/bundler_cache",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just agreed with you when you said not writing to HOME would be ideal. But I'm not hugely bothered by it, so we can leave this as it is.

Sorry, yeh, provided insufficient context here: there's additional complexity from not writing to HOME e.g. permissions, directory not existing, etc. that means that I think it's not worthwhile given the level of demand we've seen (one person 😅)

},
HOMEBREW_CACHE: {
description: "Use this directory as the download cache.",
default_text: "macOS: `$HOME/Library/Caches/Homebrew`, " \
Expand Down
3 changes: 3 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions Library/Homebrew/utils/gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions bin/brew
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ MANPAGE_VARS=(
BAT_CONFIG_PATH
BAT_THEME
BROWSER
BUNDLE_USER_CACHE
DISPLAY
EDITOR
NO_COLOR
Expand Down
4 changes: 4 additions & 0 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading