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: handle unexpected .brew presence/absence #13136

Merged
merged 1 commit into from Apr 13, 2022

Conversation

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

This fixes two complementary errors I've seen recently:

  • formula_installer.rb: when running brew reinstall, reinstall.rb checks for the existing keg via its opt prefix and backs it up to #{path}.reinstall if it exists. But if for some reason that opt prefix symlink is missing, the installer will happily overwrite the existing keg in-place… until it attempts to create the ".brew" folder, which throws Error: File exists @ dir_s_mkdir - /usr/local/Cellar/<formula>/<version>/.brew. Swapping mkpath for mkdir avoids the error.
  • formula_cellar_checks.rb: some bottles that have been around for a while (e.g. yajl) lack the ".brew" directory, which causes check_cpuid_instruction to complain with Error: No such file or directory @ rb_sysopen - /usr/local/opt/<formula>/.brew/<formula>.rb when installing. I updated it to a) check for an Intel CPU first, and b) check for the full path to the .brew/<formula>.rb file before attempting to read it.

@BrewTestBot
Copy link
Member

Review period will end on 2022-04-13 at 21:56:31 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Apr 12, 2022
Copy link
Member

@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.

These make sense to me.

@BrewTestBot BrewTestBot added waiting for feedback Merging is blocked until sufficient time has passed for review and removed waiting for feedback Merging is blocked until sufficient time has passed for review labels Apr 13, 2022
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.

Looks good but optional DRY up.

Library/Homebrew/formula_cellar_checks.rb Outdated Show resolved Hide resolved
@MikeMcQuaid MikeMcQuaid added the critical Critical change which should be shipped as soon as possible. label Apr 13, 2022
@MikeMcQuaid
Copy link
Member

Thanks again @EricFromCanada!

@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 Apr 13, 2022
@MikeMcQuaid MikeMcQuaid merged commit 62fe301 into Homebrew:master Apr 13, 2022
@EricFromCanada EricFromCanada deleted the reinstall-fixes branch April 13, 2022 15:34
@github-actions github-actions bot added the outdated PR was locked due to age label May 14, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2022
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.

None yet

4 participants