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
cmd/install: add messaging for installing edited formulae under API #14807
Conversation
Review period skipped due to |
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.
This looks great, thanks @Bo98!
It would be cool to check to see whether the modified files match the formulae being installed, but it definitely not worth it if it's more than a few extra lines of code.
To clarify, is the reason we're not defaulting to a local install in these cases because of security?
The main reason is because we optimise for the other use cases, which are far more common (most people don't edit formulae so requiring a few minute long clone for a I suppose we could make it so these specific set of conditions (if tightened a bit more) used a local install. Not sure how complex that would be. I think the way it would work would be we would "re-load" the formula wrapped in the Though there might be cases of people editing a formula years ago and forgetting about it. Because the tap doesn't get updated anymore it'll remain on the old version forever rather than regularly rebased. |
Pre 4.0.0, modifying a formula file meant you got a modified install, so feel like it makes sense to do that here too in these particular cases. I would like to hear what others think since this is yet another behavior change. Basically, I think I'm suggesting something like this (not complete code or tested) if args.build_from_source? && !Homebrew::EnvConfig.no_install_from_api? && CoreTap.instance.installed?
core_path = CoreTap.instance.path
if ((core_path.git_origin_branch.present? && !core_path.git_default_origin_branch?) || core_path.git_dirty?) &&
formulae.any? { |f| f.core_formula? && # check whether the formula is the one modified }
if Homebrew::EnvConfig.developer? || ENV["HOMEBREW_DEV_CMD_RUN"].present?
opoo "Local changes to Homebrew/core detected for the following formulae: #{formulae.map(:name)}"
puts "Using the local definitions instead of the API."
puts "If you don't know what these edits are, run `brew untap Homebrew/core`."
# Reload the formulae that need it
elsif !Homebrew::EnvConfig.no_env_hints?
opoo "Local changes to Homebrew/core detected."
puts "Homebrew no longer reads from local Homebrew/core clones by default."
puts "If you are intentionally making an edit to Homebrew/core formula,"
puts "set HOMEBREW_NO_INSTALL_FROM_API for your local clone to be used."
puts "If you don't know what these edits are, run `brew untap Homebrew/core`."
end
end
end So, modifications for a formula being installed result in developers using the local version and everyone else using the API version, with appropriate messaging either way. Is that too complicated/confusing? |
I really like this change. It'd be nice if it could be more targeted to the specific formula that is being installed but it might not be worth the added complexity. @Rylan12 brings up a good point about this being a breaking change. Have people been complaining about the change so far? When was it released? |
It shipped with 4.0.0 and the only "complaints" (more confusion really) are from those who followed the old formula cookbook since we didn't update that initially. Well, there was one complaint that It's a workflow change we made ourselves too by adding that env to Homebrew/core CI. Overall aside from the cookbook confusion, it's gone well. I've yet to see any reports of a There is also the If not then yeah automatic checking based on modified files sounds like the way to go, if paired with the warning like Rylan has proposed (don't want to reintroduce the "forgotten modification" problem given we don't auto-rebase anymore) |
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 for the explaining all that. In that case, I think this is the right approach. I'd rather have the user explicitly choose to use their local changes instead of doing it automatically which might end up even being more confusing in some cases.
The --local
option is interesting but I don't think it needs to be handled here. That would probably need to be added to a few commands, right?
We tell people to never file reports for
Yeh, I really like this idea. I think it makes much more sense than replacing a random command. I think it also might be nice to always require it for
Agreed, shouldn't block this PR. |
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 so far!
puts "Homebrew no longer reads from local Homebrew/core clones by default." | ||
puts "If you are intentionally making an edit to Homebrew/core formula," | ||
puts "set HOMEBREW_NO_INSTALL_FROM_API for your local clone to be used." | ||
puts "If you don't know what these edits are, run `brew untap Homebrew/core`." |
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.
puts "If you don't know what these edits are, run `brew untap Homebrew/core`." | |
puts "If you don't know what these edits are, run:" | |
puts " brew untap homebrew/core" |
if args.build_from_source? && !Homebrew::EnvConfig.no_install_from_api? && !Homebrew::EnvConfig.developer? && | ||
!Homebrew::EnvConfig.no_env_hints? && formulae.any?(&:core_formula?) && CoreTap.instance.installed? |
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.
Feels like this should maybe be in Library/Homebrew/install.rb
so it can be used in both cmd/upgrade.rb
and cmd/reinstall.rb
.
puts "If you are intentionally making an edit to Homebrew/core formula," | ||
puts "set HOMEBREW_NO_INSTALL_FROM_API for your local clone to be used." |
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.
puts "If you are intentionally making an edit to Homebrew/core formula," | |
puts "set HOMEBREW_NO_INSTALL_FROM_API for your local clone to be used." | |
puts "If you are intentionally making an edit to Homebrew/core formula," | |
puts "for your local clone to be used run:" | |
puts " export HOMEBREW_NO_INSTALL_FROM_API=1" |
core_path = CoreTap.instance.path | ||
if (core_path.git_origin_branch.present? && !core_path.git_default_origin_branch?) || core_path.git_dirty? | ||
opoo "Local changes to Homebrew/core detected." | ||
puts "Homebrew no longer reads from local Homebrew/core clones by default." |
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.
Would be nicer to use <<~EOS
rather than a bunch of puts
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
--build-from-source
intentionally takes a remote copy of the source code, for security & performance reasons (and because we don't actually update local clones anymore). For most people this works great.There is however a little confusing for contributors to Homebrew/core who are editing formulae. The workflow has changed slightly, as reflected in #14740.
This PR is to provide the same notice of change, but in env hint form.
This hint displays if
brew install
is being run under these conditions:--build-from-source
is passed, andHOMEBREW_NO_INSTALL_FROM_API
is not set, andHOMEBREW_DEVELOPER
is not set, andHOMEBREW_NO_ENV_HINTS
is not set, andmaster
) or there are uncommitted changes.If we want, we could possibly make it a little bit smarter by checking if the uncommitted changes apply to the formulae in question or not.