-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Use installed keg formula files when referencing installed formulae/dependencies #20603
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! A few comments. I think stubs should only be needed during the brew install/brew upgrade/maybe brew reinstall paths as most anything else will be either
- triggering an installation
- can use a formula from the Cellar
1b3e7e5 to
24aad1d
Compare
24aad1d to
16a5827
Compare
|
Okay, I've finally been able to rework this. I've added This method differs from To prevent potential issues, I've added new methods like One known issue is that running Also, the only place that @MikeMcQuaid is this approach more what you were picturing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yeh, this approach makes much more sense to me!
The only thing I'm not sure I understand is how/why the behaviour changes here compared to e.g. from_rack or from_keg?
Should e.g. from_keg perhaps be adjusted to make the changes you're looking for here?
Here's an example. Say after I've installed rack = HOMEBREW_CELLAR/"hello"
keg = Keg.new(rack/"2.12.2")
Formulary.from_rack(rack).license # => "GPL-3.0-or-later"
Formulary.from_keg(keg).license # => "GPL-3.0-or-later"
Formulary.from_installed("hello").license # => "MIT"
brew/Library/Homebrew/formulary.rb Lines 1239 to 1252 in 3023e6d
Maybe, but I think I'll need to go through all the current calls to |
|
Looks ok but one concern I do have is this might be just introducing a problem we have with casks: Ruby syntax can break (typically via deprecations). One of the most common bug reports we receive in homebrew-cask is someone can't uninstall their cask because the Ruby file can't be read anymore due to removed DSL. We're trying to move away from Ruby files in casks now that we install a metadata JSON file, but needs further work due to Previously this wasn't an issue with formulae as keg Ruby files are normally only read at install time (so will always be the "latest") and also only does so if Does the tab have enough information to get the information we need here? If so, can we use that? If not, is it feasible to add more information to that? |
Good point, thanks for pointing that out
For this PR, the main information that's needed from installed formulae is runtime dependencies and whether they're installed or not, which can be figured out from the tab. I'll need to look into it more |
@Rylan12 I suspect this logic predates us installing formulae into keys 😂 I think it's worth considering just making what you're proposing the new functionality for
That's fair. I do trust our test suite plus
@Bo98 we need to do better at handling these errors in Casks. Formulae have been a lot more rock-solid in this way because we don't rely on e.g. a formula file being valid at uninstall time. We shouldn't avoid this approach just because Casks do it poorly.
@Bo98 How much is this about pouring from bottles vs. building from source?
The tab doesn't solve all our backwards-compatibility/deprecation problems. Arguably it makes them worse because we don't really have a meaningful way to deprecate tabs. |
This already came up before - maybe Belgium or one of the maintainer calls? There was some consensus towards moving towards the formula model by migrating away from Some of that reasoning was because we have already have attempted error handling in formulae for other areas and this has typically not performed very well or at least not well enough to reliably always work. We do try for brew/Library/Homebrew/dev-cmd/extract.rb Lines 176 to 238 in 34be148
And for brew/Library/Homebrew/formula_versions.rb Lines 59 to 65 in 34be148
Though in the latter case we just simply skip reading altogether as when a Ruby file fails to load it's hard to recover. Refusing to uninstall a cask because it's unreadable isn't much better of a situation.
I'm talking entirely about the pour from bottle case. If you want to talk about build from source, that's every formula but that's again only at install time and we download the latest from GitHub so not really an issue there.
I disagree as the syntax of the tab is much easier to handle backwards compatibility for. Where removing DSL always causes a Ruby error, we have successfully removed things from the tab over the years without even needing a compatiblity layer. We also have a |
I disagree with this really. It works very reliably for formulae given how regularly we're deprecating DSLs. It is not 100% reliable and no design ever will be.
I agree, it's a worse situation. We should instead be, in the short-term, using the newest cask's
I don't think the The main issue here is a design one: Casks needing to be able to read a Ruby file indefinitely to Anyone this is all pretty heavily off-topic here. @Bo98 If you have specific objections with specific lines of code in this PR and how they will break things: please leave comments on them. If it's a general concern with the approach: please specifically propose another one in enough detail that it can be compared with this one. |
I'm confused - that's exactly the point I'm making. I'm saying the approach in this PR of having to read a Ruby file indefinitely for formulae wouldn't be great either. Every point I've made here has been centred around this. I've also been saying the Cask way of doing things sucks and we've made some progress in moving away from reading Ruby files there. |
@Bo98 Can you elaborate on what specific changes are concerning? The code on this PR does not seem to be adding additional cases where we're reading Ruby from files where we've been explicitly reading them from e.g. JSON before? Again: can you comment on specific lines on code where you see specific behaviour changes and explain in what circumstances (ideally with at least vaguely reproducible test cases) that you see them failing?
Reading Ruby files indefinitely for formulae is much less problematic than casks. If we're doing an With Casks: by design there's non-trivial logic that always wants to use the old version of the Cask at uninstall time. This can make things blow up at uninstall time (something I've not seen in a while that hasn't been very quickly fixed, worst case has been some warnings that are repeated unnecessarily). If Casks were rock-solid and entirely using the JSON-based approach and we're having new problems with them AND we were proposing moving formulae further away from that approach AND formulae had the same uninstall characteristics: yes, that would be a bad idea. As-of now, though: this is a piece in trying to get a much more minimal JSON API released soon. @Rylan12 is on a time-limited project here and we're running the very real risk in preventing this work from shipping at all if we're going to blow up the complexity or introduce uncertainty. Just to repeat and be super explcit, what I'd love to see here:
Hope the context is helpful. Happy to answer any more questions here or privately as desired ❤️ |
This PR adds
Rylan seemed to understand my comment fine based on his reply and 👍. I trust if he didn't that he would have either asked for clarification or, given I did not hit "request changes", can still choose to waive the non-blocking comment. After making my initial comment, I made sure to wait for Rylan's reply to confirm if he understood or if I was mistaken (which I always can be, and still can be here). Given there seems to be a time urgency to ship this ASAP that I was not aware of and I seem to have caused huge problems here, I'll step back from all further code review for now and will self-reflect privately. |
Just to be super explicit here: you definitely haven't caused huge problems here. We really value your feedback here, it's just that I was unable to translate your feedback into direct action items. I'd like to apologise for my suboptimal communication here too: it has fallen short of the standards I should be held to. Thanks for your input and we'll move forward with it in mind ❤️ |
16a5827 to
7c71554
Compare
|
Thanks for the discussion @Bo98 and @MikeMcQuaid ❤️ I've just pushed a change that I hope will help alleviate the concern here. Now, The reason we are trying to avoid I still want to fiddle a little bit more locally before marking this as ready for review, but I think it's very close, assuming the code looks good to everyone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
As a consequence of this PR, |
7c71554 to
318252b
Compare
|
I know there are still some test failures that I'm trying to pin down, but I think this is now mostly there. Now, the difference between the
Future work: improving |
|
Thanks @Rylan12! Will look in more detail tomorrow and happy to help with test failures if you get blocked.
Sounds good.
Makes sense, thanks again! |
@MikeMcQuaid Are there specific cases that you're worried about with the modified |
Seems fine then. Would rather avoid adding new methods if we can avoid it.
Nah, just thought if it was very easy it'd be worth persisting existing behaviour. No big deal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks @Rylan12!
318252b to
59da63e
Compare
|
The |
59da63e to
f3d44d8
Compare
|
Okay, as per usual, the fix ended up being incredibly simple, yet only apparent after days of troubleshooting 🤦 Anyway, I think this is ready now! I want to wait until just after the next release to merge in case there are issues |
As promised in slack, this PR includes the changes necessary to finally
brew installandbrew uninstallusing only the internal API.To test, run:
Importantly, the full
formula.jws.jsonfile was not downloaded during this process.