From 2daae5e84d2431a071d896d580d49b291b93b3f5 Mon Sep 17 00:00:00 2001 From: Sanjito Kurniawan Date: Fri, 10 Feb 2023 12:07:58 +0100 Subject: [PATCH 1/2] edit: add HOMEBREW_NO_INSTALL_FROM_API warning. --- Library/Homebrew/dev-cmd/edit.rb | 13 +++++++++++++ Library/Homebrew/test/dev-cmd/edit_spec.rb | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/edit.rb b/Library/Homebrew/dev-cmd/edit.rb index 04d400d2c979c..a0ae457abe374 100644 --- a/Library/Homebrew/dev-cmd/edit.rb +++ b/Library/Homebrew/dev-cmd/edit.rb @@ -78,6 +78,19 @@ def edit end.presence end + if Homebrew::EnvConfig.automatically_set_no_install_from_api? && + !Homebrew::EnvConfig.no_env_hints? + paths.each do |path| + next if !path.fnmatch?("**/homebrew-core/Formula/*.rb") && !path.fnmatch?("**/homebrew-cask/Casks/*.rb") + + opoo <<~EOS + Unless `HOMEBREW_NO_INSTALL_FROM_API` is set when running + `brew install`, it will ignore your locally edited formula. + EOS + break + end + end + if args.print_path? paths.each(&method(:puts)) return diff --git a/Library/Homebrew/test/dev-cmd/edit_spec.rb b/Library/Homebrew/test/dev-cmd/edit_spec.rb index 59e1eebea6c90..eb926a93e15ba 100644 --- a/Library/Homebrew/test/dev-cmd/edit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/edit_spec.rb @@ -13,7 +13,7 @@ setup_test_formula "testball" - expect { brew "edit", "testball", "HOMEBREW_EDITOR" => "/bin/cat" } + expect { brew "edit", "testball", "HOMEBREW_EDITOR" => "/bin/cat", "HOMEBREW_NO_ENV_HINTS" => "1" } .to output(/# something here/).to_stdout .and not_to_output.to_stderr .and be_a_success From c7b8b3a989a241e82fc40eb29493d16b32ce2fca Mon Sep 17 00:00:00 2001 From: Sanjito Kurniawan Date: Thu, 9 Feb 2023 17:57:47 +0100 Subject: [PATCH 2/2] docs/FAQ: correct an entry regarding simple formula edit Co-authored-by: Kevin --- docs/FAQ.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/FAQ.md b/docs/FAQ.md index 136839f9b79e1..cbdaaf9281757 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -142,6 +142,8 @@ If all maintainer feedback has been addressed and all tests are passing, bump it Yes! It’s easy! Just `brew edit `. You don’t have to submit modifications back to `homebrew/core`, just edit the formula to what you personally need and `brew install `. 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! +Note that if you are editing a core formula or cask you must set `HOMEBREW_NO_INSTALL_WITH_API=1` before using `brew install` or `brew update` otherwise they will ignore your local changes and default to the API. + ## Can I make new formulae? Yes! It’s easy! Just `brew create URL`. Homebrew will then open the formula in `EDITOR` so you can edit it, but it probably already installs; try it: `brew install `. If you encounter any issues, run the command with the `--debug` switch like so: `brew install --debug `, which drops you into a debugging shell.