Skip to content

Conversation

@coffeejunk
Copy link
Contributor

Fedora immutable systems use /home as a symlink to /var/home. Homebrew has code in brew.sh (lines 76-94) to normalize HOMEBREW_PREFIX and HOMEBREW_REPOSITORY for this situation, but it didn't normalize HOMEBREW_CELLAR. This caused a path mismatch when creating symlinks; for example:

  • Destination: /home/linuxbrew/.linuxbrew/opt/gum (using symlink)
  • Source: /var/home/linuxbrew/.linuxbrew/Cellar/gum/0.17.0 (using real path)

Ruby's relative_path_from then generated broken symlinks like ../../../../var/home/linuxbrew/.linuxbrew/Cellar/gum/0.17.0.

The commit adds normalization for HOMEBREW_CELLAR in Library/Homebrew/brew.sh to ensure it uses /home consistently with HOMEBREW_PREFIX.

Without the patch

$ brew install jq
✔︎ JSON API cask.jws.json
✔︎ JSON API formula.jws.json
==> Fetching downloads for: jq
✔︎ Bottle Manifest jq (1.8.1)
✔︎ Bottle Manifest oniguruma (6.9.10)
✔︎ Bottle oniguruma (6.9.10)
✔︎ Bottle jq (1.8.1)
==> Installing jq dependency: oniguruma
==> Pouring oniguruma--6.9.10.x86_64_linux.bottle.tar.gz
Error: No such file or directory @ rb_sysopen - /home/linuxbrew/.linuxbrew/opt/oniguruma/.sbom.spdx.json20251105-58550-9j303o

$ ls -la /home/linuxbrew/.linuxbrew/var/homebrew/linked/
total 36
drwxr-xr-x. 1 max  max       100 Nov  5 14:22 .
drwxrwxr-x. 1 root linuxbrew  22 Nov  5 13:02 ..
lrwxrwxrwx. 1 max  max        71 Nov  5 14:22 oniguruma -> ../../../../../../var/home/linuxbrew/.linuxbrew/Cellar/oniguruma/6.9.10

With the patch

$ brew install jq
==> Fetching downloads for: jq
✔︎ Bottle Manifest jq (1.8.1)
✔︎ Bottle Manifest oniguruma (6.9.10)
✔︎ Bottle oniguruma (6.9.10)
✔︎ Bottle jq (1.8.1)
==> Installing jq dependency: oniguruma
==> Pouring oniguruma--6.9.10.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/oniguruma/6.9.10: 16 files, 1.7MB
==> Pouring jq--1.8.1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/jq/1.8.1: 21 files, 1.4MB
==> Running `brew cleanup jq`...
Disable this behaviour by setting `HOMEBREW_NO_INSTALL_CLEANUP=1`.
Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
$ jq
jq - commandline JSON processor [version 1.8.1]
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

…th `HOMEBREW_PREFIX`

Fedora immutable systems use `/home` as a symlink to `/var/home`. Homebrew has code in `brew.sh` (lines 76-94) to normalize `HOMEBREW_PREFIX` and `HOMEBREW_REPOSITORY` for this situation, but it didn't normalize `HOMEBREW_CELLAR`. This caused a path mismatch when creating symlinks; for example:

- Destination: `/home/linuxbrew/.linuxbrew/opt/gum` (using symlink)
- Source: `/var/home/linuxbrew/.linuxbrew/Cellar/gum/0.17.0` (using real path)

Ruby's `relative_path_from` then generated broken symlinks like `../../../../var/home/linuxbrew/.linuxbrew/Cellar/gum/0.17.0`.

The commit adds normalization for `HOMEBREW_CELLAR` in `Library/Homebrew/brew.sh` to ensure it uses `/home` consistently with `HOMEBREW_PREFIX`.
Copilot AI review requested due to automatic review settings November 5, 2025 19:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for systems where HOMEBREW_CELLAR's parent directory is a symlink (e.g., Fedora Silverblue) and fixes a typo in a related comment. The changes ensure that when the resolved path of the default cellar location matches the current HOMEBREW_CELLAR, the default prefix path is used instead for consistency.

  • Added symlink resolution logic for HOMEBREW_CELLAR similar to existing logic for HOMEBREW_PREFIX and HOMEBREW_REPOSITORY
  • Fixed typo in comment at line 82 (added missing / in /var/home)
Comments suppressed due to low confidence (1)

Library/Homebrew/brew.sh:90

  • Corrected spelling of 'var/home' to '/var/home'.
# Example: Fedora Silverblue symlinks /home -> var/home

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, makes sense to me and don't think it should cause any regressions on other configurations. Great work @coffeejunk, you rock!

Maintainers: if this does cause ANY reported regressions, please favour reverting rather than waiting for someone else to fix forward ❤️

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Nov 7, 2025
Merged via the queue into Homebrew:main with commit 80bae4c Nov 7, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants