[CLI] Fix installation method detection for curl-installed hf with Homebrew Python#4142
Merged
Merged
Conversation
…mebrew Python The _is_brew_installation() check was matching before _is_hf_installer_installation() when the user's system Python came from Homebrew. This caused 'hf env' to report 'Installation method: brew' even when hf was installed via the curl installer. Two fixes: 1. Reorder checks: hf_installer (marker file) is checked before brew (heuristic) 2. Tighten brew detection: check sys.prefix for '/Cellar/hf/' (the formula's libexec venv) instead of sys.executable for '/opt/homebrew/' (which matches any Homebrew-installed Python) Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
Member
|
agree with this approach, should work! |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Contributor
|
This PR has been shipped as part of the v1.13.0 release. |
Member
|
i can confirm this is now solved: $ hf env
Copy-and-paste the text below in your GitHub issue.
- huggingface_hub version: 1.13.0
- Platform: macOS-26.4.1-arm64-arm-64bit-Mach-O
- Python version: 3.14.4
[...]
- Token path ?: /Users/gibbon/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: julien-c
- Configured git credential helpers: osxkeychain
- Run by AI agent ?: No
- Installation method: hf_installer
[...] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context: https://huggingface.slack.com/archives/C07KX53FZTK/p1777043578920709
Summary
Fixes
hf envreportingInstallation method: brewwhenhfwas actually installed via the curl installer (curl -LsSf https://hf.co/cli/install.sh | bash) on a system where Python comes from Homebrew.Root cause:
_is_brew_installation()was checked before_is_hf_installer_installation()ininstallation_method(). The brew check usedsys.executableresolved through symlinks, which points back to Homebrew's Python (e.g./opt/homebrew/Cellar/python@3.12/...) even when running inside the curl installer's venv. Since the old check matched on/opt/homebrew/prefix, it would always win.Fix:
_is_hf_installer_installation()(uses a definitive marker file) is now checked before the brew heuristicsys.prefix(the venv/prefix root) for/Cellar/hf/instead of checkingsys.executablefor/opt/homebrew/. The brew formula's libexec venv lives at e.g./opt/homebrew/Cellar/hf/0.30.0/libexec/, so this is specific to actual brew installsScenarios:
sys.prefixsys.executable(resolved)brew install hf/opt/homebrew/Cellar/hf/0.30/libexec/opt/homebrew/Cellar/python@3.12/.../python3.12~/.local/share/hf/venv/opt/homebrew/Cellar/python@3.12/.../python3.12pip install+ Homebrew Python/opt/homebrew/opt/python@3.12/.../opt/homebrew/Cellar/python@3.12/.../python3.12Slack Thread