Skip to content

Automatic cleanup on install/upgrade removes resouce data used by multiple formula (e.g., 3.13-sysconfig.diff for both python@3.{13,14}) #21327

@XuehaiPan

Description

@XuehaiPan

brew doctor output

Warning: Your Homebrew's prefix is not /home/linuxbrew/.linuxbrew.

Most of Homebrew's bottles (binary packages) can only be used with the default prefix.
Consider uninstalling Homebrew and reinstalling into the default prefix.

This is a Tier 3 configuration:
  https://docs.brew.sh/Support-Tiers#tier-3
You can report Tier 3 unrelated issues to Homebrew/* repositories!
Read the above document before opening any issues or PRs.

Verification

  • I ran brew update twice and am still able to reproduce my issue.
  • My "brew doctor output" above says Your system is ready to brew or a definitely unrelated Tier message.
  • 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.

brew config output

HOMEBREW_VERSION: 5.0.7-86-ga3338c7
ORIGIN: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
HEAD: a3338c79dba64639b01683cc33ac39f9774b8098
Last commit: 12 hours ago
Branch: main
Core tap origin: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
Core tap HEAD: 43734178bf6cf81d11e5b218834d0b1f39135bb1
Core tap last commit: 2 hours ago
Core tap JSON: 13 Sep 17:31 UTC
HOMEBREW_PREFIX: /home/panxuehai/.linuxbrew
HOMEBREW_REPOSITORY: /home/panxuehai/.linuxbrew/Homebrew
HOMEBREW_CELLAR: /home/panxuehai/.linuxbrew/Cellar
HOMEBREW_API_DOMAIN: https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api
HOMEBREW_BAT: set
HOMEBREW_BAT_THEME: Monokai Extended
HOMEBREW_BOTTLE_DOMAIN: https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
HOMEBREW_BREW_GIT_REMOTE: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
HOMEBREW_CASK_OPTS: []
HOMEBREW_CLEANUP_MAX_AGE_DAYS: 7
HOMEBREW_CORE_GIT_REMOTE: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
HOMEBREW_DISPLAY: localhost:11.0
HOMEBREW_DOWNLOAD_CONCURRENCY: 176
HOMEBREW_EDITOR: vim
HOMEBREW_FORBID_PACKAGES_FROM_PATHS: set
HOMEBREW_FORCE_VENDOR_RUBY: set
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_MAKE_JOBS: 88
HOMEBREW_NO_ANALYTICS: set
HOMEBREW_PIP_INDEX_URL: https://pypi.tuna.tsinghua.edu.cn/simple
HOMEBREW_SORBET_RUNTIME: set
all_proxy: socks5://127.0.0.1:7891
ftp_proxy: http://127.0.0.1:7890
http_proxy: http://127.0.0.1:7890
https_proxy: http://127.0.0.1:7890
Homebrew Ruby: 3.4.8 => /home/panxuehai/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/3.4.8/bin/ruby
CPU: 88-core 64-bit broadwell
Clang: 21.1.8
Git: 2.52.0 => /home/panxuehai/.linuxbrew/bin/git
Curl: 8.5.0 => /bin/curl
Kernel: Linux 6.14.0-36-generic x86_64 GNU/Linux
OS: Ubuntu 24.04.3 LTS (noble)
Host glibc: 2.39
Host libstdc++: 6.0.33
/usr/bin/gcc: 13.3.0
/usr/bin/ruby: 3.2.3
glibc: N/A
gcc@12: N/A
gcc: 15.2.0
xorg: N/A

What were you trying to do (and why)?

I'm runing brew ugprade which upgading python@3.14 and python@3.13.

python@3.14 and python@3.13 downloads the same patch:

  patch do
    url "https://raw.githubusercontent.com/Homebrew/homebrew-core/1cf441a0/Patches/python/3.13-sysconfig.diff"
    sha256 "9f2eae1d08720b06ac3d9ef1999c09388b9db39dfb52687fc261ff820bff20c3"
  end

brew upgrade automatically runs brew cleanup python@3.14 after upgrading python@3.14. However, the patch file is removed after that and then the subsequent python@3.13 upgrade fails due to missing files.

What happened (include all command output)?

$ brew upgrade
==> Feching downloads for: python@3.14, python@3.13, ... and ...
Warning: Building python@3.14 from source as the bottle needs:
- `HOMEBREW_CELLER=/home/linuxbrew/.linuxbrew/Celler` (yours is /home/panxuehai/.linuxbrew/Cellar)
- `HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew` (yours is /home/panxuehai/.linuxbrew)
==> Verifying checksum for ...
...

==> Upgrading python@3.14
  3.14.0_1 -> 3.14.2
...
==> Caveats
...
==> Summary
...
==> Running `brew cleanup python@3.14` ...
Removing: /home/panxuehai/.linuxbrew/Cellar/python@3.14/3.14.0_1... (9,198 files, 239.5MB)
Removing: /home/panxuehai/.cache/HOmebrew/python@3.14--patch--9f2eae1d08720b06ac3d9ef1999c09388b9db39dfb52687fc261ff820bff20c3.diff... (1.8KB)
==> Upgrading python@3.13
  3.13.9_1 -> 3.13.11
...
Error: An exception occurred withing a child process:
  Errno::ENOENT: No such file or directory @ rb_sysopen - f72a2b1bbc0689505bf1f874e0081c68fc125dfe72b6746325074af29fa84897--3.13-sysconfig.diff

What did you expect to happen?

Successfully upgrade python@3.13.

Step-by-step reproduction instructions (by running brew commands)

$ brew install python@3.14 python@3.13

...

$ brew upgrade  # upgrade python@3.14 python@3.13

Simluation for auto cleanup, which removes the patch file in $(brew --cache)/downloads:

$ brew fetch --build-from-source python@3.14 python@3.13
Fetching: python@3.14, python@3.13
✔︎ Formula python@3.14 (3.14.2)                                                                 Verified     30.6MB/ 30.6MB
✔︎ Resource python@3.14--flit-core                                                              Verified     53.7KB/ 53.7KB
✔︎ Resource python@3.14--pip                                                                    Verified      1.8MB/  1.8MB
✔︎ Resource python@3.14--wheel                                                                  Verified    107.5KB/107.5KB
✔︎ Patch 3.13-sysconfig.diff                                                                    Verified      1.8KB/  1.8KB
✔︎ Formula python@3.13 (3.13.11)                                                                Verified     29.4MB/ 29.4MB

$ ls "$(brew --cache)/downloads"
1b008eaca53d469b6110de5cddda0574c58ebcd4465c56c398c92abb3957ffc5--Python-3.13.11.tgz
1e1011b3ce5323399f018a4fcdf9c860d74244bf7be9d30ad2ae686f6a37f57a--wheel-0.45.1.tar.gz
2ef2f28d5350a4addbfdd0b311c016b6cab946dae59a20d91a6475ff529ede74--flit_core-3.12.0.tar.gz
456348759b7490f3822ecf2e43efc8cede32952ab6c7d9bf79812587c97164ae--Python-3.14.2.tgz
e2c0c18ff7954d85c54e25dc323bfca3cbda5548a905ba8fda24e81f1b0ae98d--pip-25.3.tar.gz
f72a2b1bbc0689505bf1f874e0081c68fc125dfe72b6746325074af29fa84897--3.13-sysconfig.diff

$ brew cleanup python@3.14
Removing: /home/panxuehai/.cache/Homebrew/python@3.14--patch--9f2eae1d08720b06ac3d9ef1999c09388b9db39dfb52687fc261ff820bff20c3.diff... (1.8KB)
==> This operation has freed approximately 1.8KB of disk space.

$ ls "$(brew --cache)/downloads"
1b008eaca53d469b6110de5cddda0574c58ebcd4465c56c398c92abb3957ffc5--Python-3.13.11.tgz
1e1011b3ce5323399f018a4fcdf9c860d74244bf7be9d30ad2ae686f6a37f57a--wheel-0.45.1.tar.gz
2ef2f28d5350a4addbfdd0b311c016b6cab946dae59a20d91a6475ff529ede74--flit_core-3.12.0.tar.gz
456348759b7490f3822ecf2e43efc8cede32952ab6c7d9bf79812587c97164ae--Python-3.14.2.tgz
e2c0c18ff7954d85c54e25dc323bfca3cbda5548a905ba8fda24e81f1b0ae98d--pip-25.3.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedWe want help addressing this

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions