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

Update documentation for brew install and FAQ regarding HOMEBREW_NO_INSTALL_FROM_API #14570

Merged
merged 2 commits into from Feb 14, 2023

Conversation

s4nji
Copy link
Contributor

@s4nji s4nji commented Feb 9, 2023

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

I was very confused why brew install was seemingly ignoring the changes I did through brew edit, only to find out after quite some time that it doesn't use the local git repository/formula anymore unless a flag is provided: #14473

This PR:

  • Adds a line regarding HOMEBREW_NO_INSTALL_FROM_API to brew install help documentation
  • Correct a (now misleading) FAQ entry on how to edit a formula, adding HOMEBREW_NO_INSTALL_FROM_API=1 flag to the brew install snippet.

@MikeMcQuaid
Copy link
Member

Thanks for the PR @s4nji! I think we'll want to think a little more about the best flow here. Any thoughts @carlocab @Rylan12 @Bo98?

Comment on lines 35 to 37

Unless `HOMEBREW_NO_INSTALL_FROM_API` is set, `brew install` will ignore your locally edited formula
done using `brew edit`.
Copy link
Member

@carlocab carlocab Feb 10, 2023

Choose a reason for hiding this comment

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

I think this should be documented in brew edit instead. Most users of brew install probably aren't interested in this information, but all users of brew edit will probably need to know it.

Maybe brew edit can print a warning that can be silenced with HOMEBREW_NO_ENV_HINTS? We could probably also drop the reference to HOMEBREW_NO_INSTALL_FROM_API in the FAQ below if we do this.

Copy link
Contributor Author

@s4nji s4nji Feb 10, 2023

Choose a reason for hiding this comment

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

I have removed the message from install and added the warning in edit in 34a19cf.
I still think the FAQ should be updated since the command mentioned in it is flat-out wrong; I suppose people might notice the warning when they run brew edit but still...

But let me know if you'd like me to / feel free to drop 14927bb

Comment on lines 47 to 48
Unless `HOMEBREW_NO_INSTALL_FROM_API` is set when running
`brew install`, it will ignore your locally edited formula.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Unless `HOMEBREW_NO_INSTALL_FROM_API` is set when running
`brew install`, it will ignore your locally edited formula.
For your changes to take effect, you must set `HOMEBREW_NO_INSTALL_FROM_API`.

Copy link
Member

@Bo98 Bo98 Feb 10, 2023

Choose a reason for hiding this comment

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

I'd also mention this only applies to core formulae/casks too.

Ideally this message would also only display if you pass an arg to a core formula/cask and not when you edit a tap one.

Copy link
Contributor Author

@s4nji s4nji Feb 10, 2023

Choose a reason for hiding this comment

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

@Bo98 Done in 79beebe (first time writing ruby I hope it's good 👀)

@carlocab I think brew install should be mentioned explicitly since it's otherwise unclear/potentially misleading since this is printed when you run brew edit (but again please feel free to edit directly)

@MikeMcQuaid
Copy link
Member

@carlocab @Bo98 if/when either of you are happy: feel free to merge!

Copy link
Contributor

@apainintheneck apainintheneck left a comment

Choose a reason for hiding this comment

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

This definitely needs to be updated. Thanks for taking a stab at it.

Library/Homebrew/dev-cmd/edit.rb Outdated Show resolved Hide resolved
Library/Homebrew/dev-cmd/edit.rb Show resolved Hide resolved
docs/FAQ.md Outdated
@@ -140,7 +140,7 @@ If all maintainer feedback has been addressed and all tests are passing, bump it

## Can I edit formulae myself?

Yes! It’s easy! Just `brew edit <formula>`. You don’t have to submit modifications back to `homebrew/core`, just edit the formula to what you personally need and `brew install <formula>`. As a bonus, `brew update` will merge your changes with upstream so you can still keep the formula up-to-date **with** your personal modifications!
Yes! It’s easy! Just `brew edit <formula>`. You don’t have to submit modifications back to `homebrew/core`, just edit the formula to what you personally need and `HOMEBREW_NO_INSTALL_FROM_API=1 brew install <formula>`. As a bonus, `brew update` will merge your changes with upstream so you can still keep the formula up-to-date **with** your personal modifications!
Copy link
Contributor

Choose a reason for hiding this comment

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

Stupid question: does brew update need HOMEBREW_NO_INSTALL_FROM_API=1 here too?

Copy link
Contributor Author

@s4nji s4nji Feb 11, 2023

Choose a reason for hiding this comment

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

Nope, HOMEBREW_NO_INSTALL_FROM_API needs to be set only for the install.
I don't think it does anything to update.

I misunderstood and also now question if the local changes are also kept (like the FAQ entry claimed) when update is done with the API 🤔
However I think this could be a separate issue/pr if turns out to be incorrect

Copy link
Contributor

Choose a reason for hiding this comment

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

This piece of documentation is out-of-date so I'm not sure I would trust it in this case. The brew update command doesn't update the homebrew/core and homebrew/cask taps when using the API so your changes shouldn't get overwritten but no upstream changes will get merged in either.

next if (tap.core_tap? || tap == "homebrew/cask") && Homebrew::EnvConfig.install_from_api?

Copy link
Contributor

Choose a reason for hiding this comment

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

To be clear I'm not sure that changing that is within the scope of this PR but it does make me wonder how we should handle these things going forward. Passing HOMEBREW_NO_INSTALL_FROM_API implicitly every time the brew edit command is called seems to make sense until you realize that it causes unexpected behavior when using other commands.

Copy link
Member

Choose a reason for hiding this comment

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

@apainintheneck @EricFromCanada any suggestions on how to update this documentation to be both correct and helpful would be handy.

Passing HOMEBREW_NO_INSTALL_FROM_API implicitly every time the brew edit command is called seems to make sense until you realize that it causes unexpected behavior when using other commands.

Agreed this could be tweaked/improved. Don't think it's worth reverting this, though.

docs/FAQ.md Outdated Show resolved Hide resolved
@MikeMcQuaid MikeMcQuaid merged commit cedd4d3 into Homebrew:master Feb 14, 2023
@MikeMcQuaid
Copy link
Member

Thanks for the PR @s4nji, you rock!

@github-actions github-actions bot added the outdated PR was locked due to age label Mar 18, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 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