Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow brew info --json=v2 without taps with JSON API #14587

Merged
merged 1 commit into from Feb 12, 2023

Conversation

Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Feb 10, 2023

We should allow brew info --json=v2 even without the taps installed. We can just pass the downloaded JSON file along without needing to regerate the data using #to_h on the formulae and casks. I've tested this locally without homebrew/core or homebrew/cask and it seems to work with an without --variations, with --installed, and with --all --eval-all.

One thing to note: when you run brew info --json it will merge in the correct OS variations which I think makes the most sense since someone running that command probably cares about what's currently on their system. brew info --json --variations, however, will return the complete with-variations JSON file. This is consistent with the way things work with HOMEBREW_NO_INSTALL_FROM_API.

Also, while we're at it, let's fully remove the bottle API. It's already been removed from formulae.brew.sh and the --bottle switch to turn it on was hidden. I don't think we'll need to do any deprecations for it but we should revert that part if anyone complains.

@Rylan12 Rylan12 added critical Critical change which should be shipped as soon as possible. install from api Relates to API installs labels Feb 10, 2023
@BrewTestBot
Copy link
Member

Review period skipped due to critical label.

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.

While this is possible: I'm not sure it's a good idea to introduce a circular dependency here. We did that already on formulae.brew.sh and it was a bit of a nightmare to resolve.

Not opposed to adding this as-is but: let's just make sure we literally never can even attempt to generate formulae.brew.sh data from this.

@Rylan12
Copy link
Member Author

Rylan12 commented Feb 10, 2023

Yeah, good point. How about this as a long-term plan: Make a new dev command called like generate-api or something like that and have that command generate the API files that we use for formulae.brew.sh (and update CI over there to just call brew generate-api). In that command, we could enforce HOMEBREW_NO_INSTALL_FROM_API. This would also help with @SMillerDev's work on Homebrew/formulae.brew.sh#728, since we could move the API generation to this repo and use its CI here.

@MikeMcQuaid
Copy link
Member

@Rylan12 yup, sounds great 👍🏻. happy to ship this as-is.

Comment on lines +234 to +237
if loaded_from_api && Homebrew::EnvConfig.install_from_api?
json_cask = Homebrew::API::Cask.all_casks[token]
return Homebrew::API.merge_variations(json_cask)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather not have to add this code to each of the #to_h* methods. Is this functionally necessary or a performance improvement? Put another way we'll have already loaded the cask/formula from the API at this point; will the normal #to_h* method return the expected output?

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's a performance optimization, it'd be nice to have benchmarks. Also, if it's only relevant for brew info I'd rather add the code there instead of to the #to_h* methods.

Copy link
Member

Choose a reason for hiding this comment

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

Put another way we'll have already loaded the cask/formula from the API at this point; will the normal #to_h* method return the expected output?

The original implementation was non-functional: #14541

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay, that was the context I was missing. Looks like the *flight blocks are still a thorn in our side when it comes to the cask API and that's really what needs to be fixed eventually but I guess this is fine as a temporary fix.

Since we aren't using the *flight block info right now when installing from the API (we download the source instead) we could probably just revert back to the previous behavior instead of bundling each block as a string. It might actually solve this problem. I could probably get a PR related to that up by tomorrow.

Copy link
Member

Choose a reason for hiding this comment

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

Since we aren't using the *flight block info right now when installing from the API (we download the source instead) we could probably just revert back to the previous behavior instead of bundling each block as a string. It might actually solve this problem. I could probably get a PR related to that up by tomorrow.

@apainintheneck This sounds good 👍🏻

@Bo98
Copy link
Member

Bo98 commented Feb 12, 2023

This needs a rebase btw.

@apainintheneck apainintheneck dismissed their stale review February 12, 2023 07:49

No longer blocking

@MikeMcQuaid MikeMcQuaid merged commit 602972e into Homebrew:master Feb 12, 2023
@Rylan12 Rylan12 deleted the info-json-api branch February 12, 2023 16:07
@github-actions github-actions bot added the outdated PR was locked due to age label Mar 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. install from api Relates to API installs outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants