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

Support user set BUNDLE_USER_CACHE #17276

Closed
1 task done
dkav opened this issue May 10, 2024 · 14 comments · Fixed by #17304 or #17324
Closed
1 task done

Support user set BUNDLE_USER_CACHE #17276

dkav opened this issue May 10, 2024 · 14 comments · Fixed by #17304 or #17324
Assignees
Labels
features New features outdated PR was locked due to age

Comments

@dkav
Copy link
Contributor

dkav commented May 10, 2024

Verification

Provide a detailed description of the proposed feature

Have Homebrew Bundler honor BUNDLE_USER_CACHE path variable if it has been set by the user.

What is the motivation for the feature?

When Homebrew installs or updates vendor gems it creates or uses the ./bundle/cache directory ignoring BUNDLE_USER_CACHE variable set in the users environment. By the doing this it negates setting the variable in the first place.

How will the feature be relevant to at least 90% of Homebrew users?

It will not be relevant.

What alternatives to the feature have been considered?

No alternatives have been considered.

@dkav dkav added the features New features label May 10, 2024
@MikeMcQuaid
Copy link
Member

Why do you want this variable to be honoured?

That Homebrew uses Bundler should be seen as an implementation detail. This seems like a potentially small performance improvement for developer commands in exchange for a higher change of errors occurring with cache/Bundler issues.

@dkav
Copy link
Contributor Author

dkav commented May 13, 2024

I am not sure we are on the same page. Hopefully the following will add more clarity.

On macOS I have setup my shell environment to follow the XDG directory spec as much as possible. To have my preferences supported by Bundler I added the BUNDLER_USER_* variables to my profile per Bundler's instructions. Using Bundler (installed via Homebrew's Ruby formula) directly I found that my defined paths were honored and the default ~/.bundler folder was not created. However, outside my use of Bundler I found that the ~/.bundler folder was being created and used by another tool. After a little testing, I found that Homebrew's use of Bundler was the source and only the ~/.bundler/cache folder was being created.

So for me, supporting BUNDLER_USER_CACHE would reduce some confusion and potentially support a user's existing preferences.

(I did try one quick attempt at implementing a solution but I was unsuccessful.)

@MikeMcQuaid
Copy link
Member

After a little testing, I found that Homebrew's use of Bundler was the source and only the ~/.bundler/cache folder was being created.

Was anything put in it/used from it? Ideally we'd avoid creating/using these sorts of directories in Homebrew at all. I agree with avoiding writing things to $HOME is ideal if possible.

@dkav
Copy link
Contributor Author

dkav commented May 13, 2024

Yes. Standard looking compact_index folder and contents.

Attached is directory listing after running the following:

brew install-bundler-gems --groups=
rm -frd ~/.bundle
brew install-bundler-gems --add-groups=bottle
ls -R ~/.bundle > ~/Downloads/ruby-cache-ls.txt

ruby-cache-ls.txt

@dkav
Copy link
Contributor Author

dkav commented May 13, 2024

As a side note, after clearing Homebrew gems and then reinstalling the following error is consistently flagged.

Error loading RubyGems plugin "/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/plugins/yard_plugin.rb": cannot load such file -- /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/yard-0.9.36/lib/rubygems_plugin.rb (LoadError)

@Bo98
Copy link
Member

Bo98 commented May 13, 2024

Setting it unconditionally to HOMEBREW_CACHE/bundler could make sense.

after clearing Homebrew gems

How are you clearing the gems?

@dkav
Copy link
Contributor Author

dkav commented May 13, 2024

How are you clearing the gems?

Via brew install-bundler-gems --groups=

I found the solution in a comment on GitHub. It wasn't clear to me how to do it otherwise.

@Bo98
Copy link
Member

Bo98 commented May 14, 2024

Yeah that's the supported way. Will check why Bundler doesn't cleanup plugins.

@MikeMcQuaid
Copy link
Member

Setting it unconditionally to HOMEBREW_CACHE/bundler could make sense.

Agreed. Should just be an environment variable to do so.

@dkav
Copy link
Contributor Author

dkav commented May 15, 2024

On my end #17304 doesn't resolve the issue. ~/bundle reappears when running brew install-bundler-gems --add-groups=bottle. No folder is created in ~/Library/Caches/Homebrew, if that is the new location.

@carlocab
Copy link
Member

What's the output of brew config and brew doctor?

@carlocab carlocab reopened this May 15, 2024
@dkav
Copy link
Contributor Author

dkav commented May 15, 2024

brew config

HOMEBREW_VERSION: 4.3.0-22-g56db99e
ORIGIN: https://github.com/Homebrew/brew
HEAD: 56db99e
Last commit: 3 hours ago
Core tap JSON: 15 May 16:39 UTC
Core cask tap JSON: 15 May 16:39 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_CLEANUP_MAX_AGE_DAYS: 60
HOMEBREW_DEVELOPER: set
HOMEBREW_EDITOR: /opt/homebrew/bin/mvim
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_MAKE_JOBS: 8
HOMEBREW_NO_EMOJI: set
HOMEBREW_NO_ENV_HINTS: set
HOMEBREW_NO_UPDATE_REPORT_NEW: set
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.1.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: octa-core 64-bit arm_ibiza
Clang: 15.0.0 build 1500
Git: 2.45.1 => /opt/homebrew/bin/git
Curl: 8.6.0 => /usr/bin/curl
macOS: 14.5-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: N/A
Rosetta 2: false

brew doctor

Your system is ready to brew.

@MikeMcQuaid
Copy link
Member

~/bundle reappears when running brew install-bundler-gems --add-groups=bottle.

Do you have a ~/.bundle/config?

@dkav
Copy link
Contributor Author

dkav commented May 16, 2024

Do you have a ~/.bundle/config?

No. The following is my .zprofile:

export BUNDLE_USER_CONFIG=$XDG_CONFIG_HOME/bundle/config
export BUNDLE_USER_PLUGIN=$XDG_DATA_HOME/bundle
export BUNDLE_USER_CACHE=$XDG_CACHE_HOME/bundle

Output from bundle config list:

Settings are listed in order of priority. The top value will be used.
user_cache
Set via BUNDLE_USER_CACHE: "/Users/xxx/.cache/bundle"

user_config
Set via BUNDLE_USER_CONFIG: "/Users/xxx/.config/bundle/config"

user_plugin
Set via BUNDLE_USER_PLUGIN: "/Users/xxx/.local/share/bundle"

I don't have a config file so the config folder doesn't exist and is not created.

MikeMcQuaid added a commit that referenced this issue May 17, 2024
Take two at #17304 with the correct
variable name this time.

Fixes #17276.
@github-actions github-actions bot added the outdated PR was locked due to age label Jun 17, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
features New features outdated PR was locked due to age
Projects
None yet
4 participants