homebrew-bundle: `brew bundle exec` behaves unexpectedly

I have tried using brew bundle exec, but it behaves differently than I would expect. I have created a simple Brewfile that declares only Python 3.8. I expect that when I run brew bundle exec, the python3 command will point to Python 3.8. This does not seem to be the case, however – Python 3.11, which is installed globally through Brew, gets picked up instead.

~/test
❯ ls
Brewfile

~/test 
❯ cat Brewfile
tap "homebrew/bundle"
tap "homebrew/core"
brew "python@3.8"

~/test 
❯ python3 --version
Python 3.11.3

~/test 
❯ brew bundle --file=Brewfile exec -- python3 --version
Python 3.11.3

brew doctor shows no errors and brew update says everything is up to date. My OS is Pop!_OS 22.04 LTS, which is based on Ubuntu 22.04 LTS.

~/test 
❯ brew config
HOMEBREW_VERSION: 4.0.16
ORIGIN: https://github.com/Homebrew/brew
HEAD: 01e0c20d01c6aab28d844280d130f0e745e2ddd9
Last commit: 4 days ago
Core tap JSON: 04 May 18:12 UTC
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: :1
HOMEBREW_MAKE_JOBS: 12
Homebrew Ruby: 2.6.10 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.10_1/bin/ruby
CPU: dodeca-core 64-bit zen
Clang: N/A
Git: 2.34.1 => /bin/git
Curl: 7.81.0 => /bin/curl
Kernel: Linux 6.2.6-76060206-generic x86_64 GNU/Linux
OS: Pop!_OS 22.04 LTS (jammy)
Host glibc: 2.35
/usr/bin/gcc: 11.3.0
/usr/bin/ruby: N/A
glibc: N/A
gcc@11: N/A
gcc: N/A
xorg: N/A

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Please re-read our code of conduct and adjust your communication before making additional comments. Your tone is unnecessarily inflammatory.


Closing out this issue as the author is no longer using brew bundle and no-one else seems to care enough about this specific problem to comment or 👍🏻.

@osalbahr In your example, the $ command substitution is performed before even running the bundle command, so of course it reflects the outer shell.

At the current state, brew bundle exec is not fit for tool version managment, given that:

  • the behavior is weird regarding the resolution of the passed command
  • even after specifying a version, other versions of the same tool may leak into the environment as dependencies

I have switched to asdf for this use case and can recommend it.