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

formula_installer: restrict use of Formula from Keg #11532

Merged
merged 2 commits into from
Jun 15, 2021

Conversation

nandahkrishna
Copy link
Member

  • 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?

Restrict usage of the formula file from the bottle. Should fix #11468 (comment).

Formulae which require files from lib in the Tap could probably not get post_install to work if installing them without tapping the Tap.

@nandahkrishna nandahkrishna changed the title formula_installer: restrict use formula from bottle formula_installer: restrict use of formula from bottle Jun 14, 2021
@BrewTestBot
Copy link
Member

Review period will end on 2021-06-15 at 12:21:00 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Jun 14, 2021
@nandahkrishna nandahkrishna added the critical Critical change which should be shipped as soon as possible. label Jun 14, 2021
@BrewTestBot
Copy link
Member

Review period skipped due to critical label.

@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Jun 14, 2021
BrewTestBot
BrewTestBot previously approved these changes Jun 14, 2021
BrewTestBot
BrewTestBot previously approved these changes Jun 14, 2021
MikeMcQuaid
MikeMcQuaid previously approved these changes Jun 14, 2021
@nandahkrishna nandahkrishna dismissed stale reviews from MikeMcQuaid and BrewTestBot via 0a7be33 June 14, 2021 13:51
@nandahkrishna nandahkrishna force-pushed the bottle-install-fixes branch from 7235427 to 0a7be33 Compare June 14, 2021 13:51
BrewTestBot
BrewTestBot previously approved these changes Jun 14, 2021
@nandahkrishna
Copy link
Member Author

Just tweaked this since according to #11532 (comment), the formula will always exist in the prefix unless deleted, so the condition was redundant. We haven't seen the error mentioned there (yet), so I haven't tweaked any messaging.

@nandahkrishna nandahkrishna changed the title formula_installer: restrict use of formula from bottle formula_installer: restrict use of formula from prefix Jun 14, 2021
@nandahkrishna nandahkrishna changed the title formula_installer: restrict use of formula from prefix formula_installer: restrict use of Formula from Keg Jun 14, 2021
@nandahkrishna nandahkrishna force-pushed the bottle-install-fixes branch from 0a7be33 to 4cec90c Compare June 14, 2021 21:31
BrewTestBot
BrewTestBot previously approved these changes Jun 14, 2021
@nandahkrishna
Copy link
Member Author

nandahkrishna commented Jun 14, 2021

With the latest push, the formula from the installation prefix is used only if:

  • Installing from a local bottle, or
  • The tap isn't installed or the formula doesn't exist in the tap, or
  • The tap contains a different pkg_version of the formula (effectively applies to brew postinstall only).

I'm using formula.opt_prefix because if the tap has a newer version, formula.prefix will point to the newer version but we want to use the older version for brew postinstall. Only using the older version in this case will allow us to access the formula file from the keg, so the easiest way is to just use opt_prefix.

The formula from the tap is used in all other cases, including:

  • The tap formula's pkg_version equals the keg formula's pkg_version (whether or not the user has edited the formula in the tap).
    • If the formula has been edited in such a way that the pkg_version differs, brew postinstall will use the formula from the keg but brew install will use the formula from the tap.
  • The formula requires some libraries from a tap, making it unreadable from the keg.

I think this does what we want in all possible cases, except when the formula from the keg is unreadable and an older version is installed – we'd like to use the keg formula but it's not possible (as of now).

It took me a while to wrap my head around this, so hopefully I've got it right 😅.

BrewTestBot
BrewTestBot previously approved these changes Jun 14, 2021
MikeMcQuaid
MikeMcQuaid previously approved these changes Jun 15, 2021
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.

❤️

@nandahkrishna nandahkrishna enabled auto-merge June 15, 2021 12:03
@nandahkrishna nandahkrishna merged commit d391331 into Homebrew:master Jun 15, 2021
@nandahkrishna nandahkrishna deleted the bottle-install-fixes branch June 15, 2021 12:33
@github-actions github-actions bot added the outdated PR was locked due to age label Jul 16, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2021
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. outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants