Skip to content

Conversation

Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Oct 7, 2025

Retry #20603 again

Once again, the changes since the last attempt can be seen in 5834158 (#20830)

I realized that the root cause of the bottling issues was actually that the wrong path was being written to the bottle JSON files with brew bottle --json. This PR actually fixes this by adding a new tap_path method to formulae that returns the path that a formula would have if it was tapped, even if it's not. This allows us to write the correct path even with Formulary.resolve.

Additionally, I caught another issue where the bottle rebuild wasn't being calculated correctly (for essentially the same reason) which is also fixed.

I've also manually gone through brew bottle and the brew pr-* commands, and there are no more calls to Formula#path.


I wonder, would it be better to update Formula#path to always return the tap path and then use Formula#specified_path when the actual specified path is needed?


I'm making this a draft because I still haven't reproduce the issue @alebcay ran into, so that is not fixed


Also, to try to make this smoother for everyone, let's plan to merge this when I'm around to monitor and try to fix forward

…0753-revert-20603-install-uninstall-formulae-internal-api"

This reverts commit afdef01, reversing
changes made to ded9862.
@Rylan12 Rylan12 marked this pull request as draft October 7, 2025 01:15
@Rylan12 Rylan12 force-pushed the retry-use-installed-formulae branch from 62eb1e4 to 5834158 Compare October 7, 2025 02:03
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.

Thoughts on getting this merged (and not reverted) quicker: can this be split into as many small PRs as possible instead? Thanks for all the work here @Rylan12 🙇🏻

@MikeMcQuaid
Copy link
Member

@Rylan12 Another thought: merge at a time you and I are both around for 2-4 more hours and aim to fix forward in main?

@alebcay
Copy link
Member

alebcay commented Oct 8, 2025

If there's any information from my setup that would be helpful for trying to identify the exact issue that occurred previously, let me know and I can provide it.

I just checked out this branch and can confirm that with the current PR, brew autoremove is still attempting to remove that formula.

@MikeMcQuaid
Copy link
Member

If there's any information from my setup that would be helpful for trying to identify the exact issue that occurred previously, let me know and I can provide it.

I just checked out this branch and can confirm that with the current PR, brew autoremove is still attempting to remove that formula.

@alebcay --debug --verbose output would be a helpful start?

@Rylan12
Copy link
Member Author

Rylan12 commented Oct 8, 2025

@alebcay can you also post the install receipt for golangci-lint:

cat "$(brew --prefix golangci-lint)/INSTALL_RECEIPT.json"

@alebcay
Copy link
Member

alebcay commented Oct 8, 2025

The debug+verbose output was too long to fit, attached as a file. I didn't see anything of interest, it just shows a bunch of formulae/casks being loaded but no additional output about resolving which formulae/casks are being selected for autoremove.

autoremove.log

$ cat "$(brew --prefix golangci-lint)/INSTALL_RECEIPT.json"
{
  "homebrew_version": "4.6.11-107-g23d4a36",
  "used_options": [],
  "unused_options": [],
  "built_as_bottle": true,
  "poured_from_bottle": true,
  "loaded_from_api": true,
  "installed_as_dependency": false,
  "installed_on_request": true,
  "changed_files": [],
  "time": 1758506872,
  "source_modified_time": 1758480793,
  "compiler": "clang",
  "aliases": [],
  "runtime_dependencies": [
    {
      "full_name": "go",
      "version": "1.25.1",
      "revision": 0,
      "bottle_rebuild": 0,
      "pkg_version": "1.25.1",
      "declared_directly": true
    }
  ],
  "source": {
    "spec": "stable",
    "versions": {
      "stable": "2.5.0",
      "head": null,
      "version_scheme": 0
    },
    "path": "/Users/caleb/Library/Caches/Homebrew/api/formula.jws.json",
    "tap_git_head": "e885969cd983ef8e9fd780a31f6e396b6b15beb4",
    "tap": "homebrew/core"
  },
  "arch": "arm64",
  "built_on": {
    "os": "Macintosh",
    "os_version": "macOS 26",
    "cpu_family": "dunno",
    "xcode": "26.0",
    "clt": "26.0.0.0.1.1756965055",
    "preferred_perl": "5.34"
  }
}

@Rylan12
Copy link
Member Author

Rylan12 commented Oct 10, 2025

@alebcay thanks! Can also send the same for the go formula?

cat "$(brew --prefix go)/INSTALL_RECEIPT.json"

Do you have HOMEBREW_NO_CLEANUP_FORMULAE set (a brew config might be helpeful)?

Can you post the output of the following commands:

brew ruby -rutils/autoremove -e 'puts Utils::Autoremove.removable_formulae([Formulary.resolve("go"), Formulary.resolve("golangci-lint")], []).inspect'
brew ruby -rutils/autoremove -e 'puts Utils::Autoremove.send(:bottled_formulae_with_no_formula_dependents, [Formulary.resolve("go"), Formulary.resolve("golangci-lint")]).inspect'

@alebcay
Copy link
Member

alebcay commented Oct 10, 2025

$ cat "$(brew --prefix go)/INSTALL_RECEIPT.json"
{
  "homebrew_version": "4.6.16-47-g3269773",
  "used_options": [],
  "unused_options": [],
  "built_as_bottle": true,
  "poured_from_bottle": true,
  "loaded_from_api": true,
  "installed_as_dependency": true,
  "installed_on_request": false,
  "changed_files": [],
  "time": 1759926125,
  "source_modified_time": 1759428014,
  "compiler": "clang",
  "aliases": [
    "[email protected]",
    "golang",
    "google-go"
  ],
  "runtime_dependencies": [],
  "source": {
    "spec": "stable",
    "versions": {
      "stable": "1.25.2",
      "head": null,
      "version_scheme": 0
    },
    "path": "/Users/caleb/Library/Caches/Homebrew/api/formula.jws.json",
    "tap_git_head": "9b73146bd61dad883a54499a619925b171f5b0b8",
    "tap": "homebrew/core"
  },
  "arch": "arm64",
  "built_on": {
    "os": "Macintosh",
    "os_version": "macOS 26",
    "cpu_family": "dunno",
    "xcode": "26.0",
    "clt": "26.0.0.0.1.1756965055",
    "preferred_perl": "5.34"
  }
}
$ brew config
HOMEBREW_VERSION: 4.6.16-38-g5834158
ORIGIN: https://github.com/Homebrew/brew
HEAD: 58341589b61d3b1d045ca5ac7f9bf31a859d42de
Last commit: 4 days ago
Branch: retry-use-installed-formulae
Core tap HEAD: 7baaa1c4add2924e9e3780a72d4b114781bfb837
Core tap last commit: 2 days ago
Core tap JSON: 09 Oct 00:45 UTC
Core cask tap HEAD: 11ceeeda207565f6850a71a9e104b98eeb69d105
Core cask tap last commit: 2 days ago
Core cask tap JSON: 09 Oct 00:45 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: /Applications/VSCodium.app/Contents/Resources/app/bin/codium
HOMEBREW_FORBID_PACKAGES_FROM_PATHS: set
HOMEBREW_MAKE_JOBS: 10
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.4.5 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.4.5/bin/ruby
CPU: deca-core 64-bit arm_blizzard_avalanche
Clang: 17.0.0 build 1700
Git: 2.50.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 26.0.1-arm64
CLT: 26.0.0.0.1.1757719676
Xcode: 26.0.1
Rosetta 2: false
$ brew ruby -rutils/autoremove -e 'puts Utils::Autoremove.removable_formulae([Formulary.resolve("go"), Formulary.resolve("golangci-lint")], []).inspect'
[]
$ brew ruby -rutils/autoremove -e 'puts Utils::Autoremove.send(:bottled_formulae_with_no_formula_dependents, [Formulary.resolve("go"), Formulary.resolve("golangci-lint")]).inspect'
[#<Formula golangci-lint (stable) /opt/homebrew/opt/golangci-lint/.brew/golangci-lint.rb>]

@Rylan12
Copy link
Member Author

Rylan12 commented Oct 11, 2025

Huh, interesting. A few more for you if you don't mind @alebcay:

brew ruby -rutils/autoremove -e 'puts Utils::Autoremove.removable_formulae(Formula.installed, Cask::Caskroom.casks).inspect'
brew ruby -rcleanup -e 'puts Homebrew::Cleanup.autoremove(dry_run: true).inspect'

@alebcay
Copy link
Member

alebcay commented Oct 11, 2025

$ brew ruby -rutils/autoremove -e 'puts Utils::Autoremove.removable_formulae(Formula.installed, Cask::Caskroom.casks).inspect'
[#<Formula go (stable) /opt/homebrew/opt/go/.brew/go.rb>]
$ brew ruby -rcleanup -e 'puts Homebrew::Cleanup.autoremove(dry_run: true).inspect'
==> Would autoremove 1 unneeded formula:
go
nil

@Rylan12
Copy link
Member Author

Rylan12 commented Oct 11, 2025

Hmm, I am pretty confused and struggling to figure out how to reproduce. It seems like there must be some other go or golanci-lint dependent in Formula.installed that's interfering. Can you share these? And also the install receipts for any formulae that are returned as dependents?

brew uses --installed go
brew uses --installed golangci-lint

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.

3 participants