Repository navigation
uv tool management ignores environment and always uses CLT python #23973
Description
brew doctor output
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: Some installed casks are deprecated or disabled.
You should find replacements for the following casks:
darktableVerification
- I ran
brew updatetwice and am still able to reproduce my issue. - I have supplied my
brew doctoroutput above and it seems unrelated to my issue. - This issue's title and/or description do not reference a single formula e.g.
brew install wget. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead. - I did not use AI/LLM to create this issue, or I disclosed the tool and model used; I will answer maintainer questions myself without AI/LLM.
brew config output
HOMEBREW_VERSION: 7.0.1-15-g82ea9cb
ORIGIN: https://github.com/Homebrew/brew
HEAD: 82ea9cb60b55c00f3a65bdffb30db97a82d1e0d7
Last commit: 2 hours ago
Branch: main
Core tap HEAD: 2c70d8df74f9f227fefd7e197961d4cde9481fd2
Core tap last commit: 2 hours ago
Core cask tap HEAD: 7cb180869c4ff9cd6a822a92d8267a1579ef30de
Core cask tap last commit: 3 hours ago
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_NO_ANALYTICS: set
no_proxy: *
Homebrew Ruby: 4.0.6 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/4.0.6_2/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 21.0.0 build 2100
Git: 2.55.0 => /opt/homebrew/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 26.6.2-arm64
CLT: 27.0.0.0.1788430756
Xcode: N/A
Rosetta 2: falseWhat were you trying to do (and why)?
I moved my pipx-managed python tools to brew-managed uv-tools to get closer to a single declarative source of truth for my packages and apps (my Brewfile).
What happened (include all command output)?
I installed pre-commit via uv tool via brew bundle and it uses the wrong Python installation.
See reproduction for all commands and output.
Why it matters? It seems pre-commit uses its own python when creating pre-commit hook environments. Since it defaults to the wrong python (in my case, the CLT Python with version 3.9), I cannot install hooks which require a newer python version, e.g., the isort hook.
What did you expect to happen?
I expect uv tool to respect the UV_PYTHON environment variable (which it does outside of brew bundle), or to be able to configure a python version via the Brewfile (uv tool install accepts --python <python>, which could be passed as an argument.). Or at least use the first python on my path (which happens to be $(brew --prefix python)/bin/python3).
Step-by-step reproduction instructions (running brew commands)
$ mkdir test && cd test
$ git init
$ cat <<EOF > .pre-commit-config.yaml
heredoc> repos:
heredoc> - repo: https://github.com/PyCQA/isort
heredoc> rev: 9.0.1
heredoc> hooks:
heredoc> - id: isort
heredoc> EOF
$ export UV_PYTHON=$(brew --prefix python)/bin/python3 # optional if your Path is set up correctly
$ brew bundle --file=- <<EOF
heredoc> brew "uv"
heredoc> uv "pre-commit"
heredoc> EOF
Installing uv
Installing pre-commit
$ $(uv tool dir)/pre-commit/bin/python --version
Python 3.9.6
$ ls -l $(uv tool dir)/pre-commit/bin/python
lrwxr-xr-x@ 1 shoeffner staff 51 Sep 15 09:13 /Users/shoeffner/.local/share/uv/tools/pre-commit/bin/python -> /Library/Developer/CommandLineTools/usr/bin/python3
$ pre-commit install-hooks
[INFO] Installing environment for https://github.com/PyCQA/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Users/shoeffner/.cache/pre-commit/reporll5792n/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
stdout:
Processing ./.
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
INFO: pip is looking at multiple versions of isort to determine whichversion is compatible with other requirements. This could take a while.
stderr:
ERROR: Package 'isort' requires a different Python: 3.9.6 not in '>=3.10.0'
Check the log at /Users/shoeffner/.cache/pre-commit/pre-commit.log
$ brew bundle remove --uv pre-commit --file=- <<EOF # unrelated issue: this doesn't seem to work
heredoc> uv "pre-commit"
heredoc> EOF
$ ls $(uv tool dir)/pre-commit
CACHEDIR.TAG lib uv-receipt.toml
bin pyvenv.cfg
$ uv tool uninstall pre-commit
Uninstalled 1 executable: pre-commit
$ uv tool install pre-commit
Resolved 10 packages in 24ms
Installed 10 packages in 34ms
+ cfgv==3.5.0
+ distlib==0.4.3
+ filelock==3.32.6
+ identify==2.6.19
+ nodeenv==1.10.0
+ platformdirs==4.11.8
+ pre-commit==4.6.2
+ python-discovery==1.6.0
+ pyyaml==6.0.3
+ virtualenv==21.7.9
Installed 1 executable: pre-commit
$ $(uv tool dir)/pre-commit/bin/python --version
Python 3.14.7
$ ls -l $(uv tool dir)/pre-commit/bin/python
lrwxr-xr-x@ 1 shoeffner staff 44 Sep 15 09:29 /Users/shoeffner/.local/share/uv/tools/pre-commit/bin/python -> /opt/homebrew/opt/python@3.14/bin/python3.14
$ pre-commit install-hooks
$ pre-commit run --all --all-files
isort................................................(no files to check) Skipped
Activity
[-]uv tool management ignores environment and always uses system python[/-][+]uv tool management ignores environment and always uses CLT python[/+]MikeMcQuaid commentedon Sep 15, 2026
Yes, this is intentional. Homebrew filters the environment heavily. If you need to specify a specific python you can do this inside your
Brewfile.We'll review a PR to make it prioritise using a Python formula based on Homebrew's install state but not user
PATH.shoeffner commentedon Sep 16, 2026
Thanks, it makes sense not to rely on the PATH, indeed.
I haven't found a way to specify a specific python in my Brewfile – the
uvextension only supportswithandsourceand not thepythonparameter, nor did I find anything about telling brew which python to use by default, that doesn't mean it doesn't exist though.I could try to add the
--pythonparameter to allow a user to specify a specific python path, would you also accept a PR for that? I believe that might be more explicit and cleaner than relying on Homebrew's install state and it would allow a user to use different python versions for different uv tools.MikeMcQuaid commentedon Sep 17, 2026
Improved in #24014