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

Store and use revision in tab runtime dependencies #16152

Merged
merged 1 commit into from Nov 10, 2023

Conversation

Bo98
Copy link
Member

@Bo98 Bo98 commented Oct 27, 2023

Should fix brew upgrade <pkg> producing broken installs. We were treating two packages with the same version but different revisions as compatible (because we didn't store revision info at all). This was often incorrect and lead to several reports of broken installs.

Library/Homebrew/formula_installer.rb Outdated Show resolved Hide resolved
Library/Homebrew/dependency.rb Outdated Show resolved Hide resolved
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 for the PR! This will fix the problem but I think we don't really need a new field and would be good to tighten this up so we don't ignore all existing tabs, only a subset (e.g. those where the dependency has a higher revision than noted or something)

Library/Homebrew/tab.rb Show resolved Hide resolved
Library/Homebrew/upgrade.rb Outdated Show resolved Hide resolved
@SMillerDev
Copy link
Member

A bunch of people are reporting this every day. @MikeMcQuaid is there a chance to merge this, release and improve it further later?

@MikeMcQuaid
Copy link
Member

A bunch of people are reporting this every day. @MikeMcQuaid is there a chance to merge this, release and improve it further later?

@SMillerDev Not as-is, no. I agree it's important though and, if no-one else has picked it up by Friday, I'll try to get it merged then.

@MikeMcQuaid
Copy link
Member

@Bo98 @apainintheneck I've adjusted this to:

  • also set pkg_version field in tabs, it's more useful to non-Homebrew consumers this way
  • implement the conservative logic discussed above based on the table that @apainintheneck came up with
  • tried to make the formula_installer logic more minimal and upgrade and dependency logic more similar and better documented
  • fixed up tests and style where needed

@MikeMcQuaid
Copy link
Member

@Bo98 @apainintheneck once you're both happy: can one of you merge this? Thanks ❤️

@MikeMcQuaid MikeMcQuaid force-pushed the runtime-dep-revision branch 2 times, most recently from 0226f38 to b174c0a Compare November 10, 2023 17:17
Copy link
Member Author

@Bo98 Bo98 left a comment

Choose a reason for hiding this comment

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

I think this looks good, with this one logic tweak that should align with what was intended:

Library/Homebrew/dependency.rb Outdated Show resolved Hide resolved
Library/Homebrew/upgrade.rb Outdated Show resolved Hide resolved
@Bo98
Copy link
Member Author

Bo98 commented Nov 10, 2023

(LGTM otherwise assuming 0.present? will indeed return true - I forget with that one).

@Bo98 Bo98 force-pushed the runtime-dep-revision branch 2 times, most recently from abbecb3 to 65d9b1f Compare November 10, 2023 18:20
@Bo98
Copy link
Member Author

Bo98 commented Nov 10, 2023

Also pushed so we Version.new wrap the version field since PkgVersion.new actually needs that rather than a string. Did so on the formula installer side as a type signature of T.nilable(Version) makes sense.

Let's start storing `revision` and `pkg_version` for tab runtime
dependencies and use them when available.

When the `revision` is not available, use a conservative approach to
deciding whether dependencies need to be upgrade.

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
@MikeMcQuaid MikeMcQuaid merged commit 5e47d3a into Homebrew:master Nov 10, 2023
27 checks passed
@MikeMcQuaid
Copy link
Member

Thanks for help before and after, @Bo98!

@Bo98 Bo98 deleted the runtime-dep-revision branch November 10, 2023 19:33
@JL-EU
Copy link

JL-EU commented Nov 10, 2023

Thanks for fixing these issues. When and how can we check if these updates will work? In my situation Homebrew/homebrew-core#153593

@Bo98
Copy link
Member Author

Bo98 commented Nov 11, 2023

It will be released probably on Monday. The fix won't do anything to people with already broken installs, however such installs are fixable by updating your out-of-date formulae (even before this fix is released).

It looks like your particular issue might be bug within platformio formula itself however - I would need to look into it.

Comment on lines +69 to +70
elsif installed_version.version == minimum_version
formula.revision.zero?
Copy link
Member

Choose a reason for hiding this comment

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

I think this may be causing current CI dependent failure when only revision bumping like in https://github.com/Homebrew/homebrew-core/actions/runs/6856551968/job/18644302924?pr=154195#step:3:244

Dependent test tries to install bottle for formula that was built in PR. Not sure if just checking formula.latest_version_installed? works or if there is better option.

Copy link
Member

Choose a reason for hiding this comment

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

Can you narrow this down to the specific line and, ideally, open a PR (even if it's not fully working yet)?

The formula.revision.zero? part at least is essential here: that's basically the point of all my changes to this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed hopefully in #16220

Copy link
Member

Choose a reason for hiding this comment

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

It should be that line with reproduction by local source-building a formula with extra revision bump then trying to install deps, e.g.

$ brew bump-revision --write-only python-click
$ brew install -s python-click
$ brew install --only-dependencies airshare
...
==> Downloading https://ghcr.io/v2/homebrew/core/python-click/manifests/8.1.7_1-1
curl: (22) The requested URL returned error: 404

==> Pouring python-click--8.1.7.sonoma.bottle.1.tar.gz
Error: /usr/local/Cellar/python-click/8.1.7_1 is not a directory

Verifying latest version/revision is installed does make error go away, e.g.

Suggested change
elsif installed_version.version == minimum_version
formula.revision.zero?
elsif installed_version.version == minimum_version
formula.revision.zero? || formula.latest_version_installed?

@github-actions github-actions bot added the outdated PR was locked due to age label Dec 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants