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
Conversation
Review period will end on 2022-04-13 at 21:56:31 UTC. |
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.
These make sense to me.
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 but optional DRY up.
3c1d0ef
to
774537d
Compare
Thanks again @EricFromCanada! |
Review period skipped due to |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?This fixes two complementary errors I've seen recently:
formula_installer.rb
: when runningbrew 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 throwsError: File exists @ dir_s_mkdir - /usr/local/Cellar/<formula>/<version>/.brew
. Swappingmkpath
formkdir
avoids the error.formula_cellar_checks.rb
: some bottles that have been around for a while (e.g.yajl
) lack the ".brew" directory, which causescheck_cpuid_instruction
to complain withError: 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.