175 Commits

Author SHA1 Message Date
Mike McQuaid
45b66870bb
Improve "unknown command" error
Clarify it is a `brew` command.

Fixes #17627
2024-07-05 08:20:28 +01:00
Issy Long
509fffab2b
Make more files Sorbet typed: strict
- According to Spoom, these could be bumped automatically with no errors.
2024-06-02 15:15:24 +01:00
Mike McQuaid
28c3215dba
analytics: support command and test-bot analytics.
These are used to analyse which commands are used and the
success/failure rate of official taps using `brew test-bot`.
2024-04-25 17:38:04 +01:00
Douglas Eichelberger
98d36c30c5 Apply suggestions from code review
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2024-04-21 14:16:25 -07:00
Douglas Eichelberger
cb71938fff Enable strict typing in CLI::Parser 2024-04-21 14:16:25 -07:00
Mike McQuaid
3fe5cad8dd
brew.rb: restore old runtime error handling.
We don't want to print the report/do not report messages for these.
2024-04-04 08:51:27 +01:00
Mike McQuaid
ef19c9fc88
brew.rb: improve no auto-update exception handling.
Instead of unconditionally telling people to `brew update` rather than
not reporting the issue, only do so if they haven't run `brew update`
today.
2024-04-03 19:44:12 +01:00
Mike McQuaid
21d99c5e89
brew.rb: tell more people to not report issues.
- We should tell people to not report issues if they are running in an
  unsupported configuration.
- We should tell people to run `brew update` before reporting issues if
  they have `HOMEBREW_NO_AUTO_UPDATE` set.
- We should tell people to not report issues in more types of
  exceptions.
- Warn people in `HOMEBREW_NO_AUTO_UPDATE` documentation.
- DRY up `brew.rb` exception handling.

Co-authored-by: Colin Dean <colindean@users.noreply.github.com>
2024-04-03 08:16:01 +01:00
Douglas Eichelberger
7d34717ccd Search subclasses instead of using registry 2024-03-15 12:46:06 -07:00
Douglas Eichelberger
5364b6ef03 Use a command registry 2024-03-15 12:46:05 -07:00
Douglas Eichelberger
cbcb221de6 Create AbstractCommand class 2024-03-15 12:46:05 -07:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Patrick Linnane
9dee80cb2d
various: fix style errors 2023-12-18 09:34:01 -08:00
Bo Anderson
daa49a1323
Install gems automatically on newer Ruby 2023-09-29 01:34:39 +01:00
apainintheneck
85bd4c7e1f utils/backtrace: scrub sorbet-runtime from backtrace
Ever since we started using this at runtime it's been polluting
the backtrace output. This makes it harder to debug errors and
increases the amount of info users have to paste into the box
when filing an issue.

This is a very direct approach. Essentially, we strip out
everything related to the `sorbet-runtime` gem whenever the top
line in the backtrace is unrelated to sorbet-runtime.

The hope is that this will allow errors related to sorbet to
be diagnosed easily while also reducing the backtrace size
for all other types of errors.

Sometimes it is useful to see the full backtrace though.
For those cases, we include the full backtrace when
`--verbose` is passed in and print a warning that the
Sorbet lines have been removed from the backtrace the
first time they are removed.

Note: This requires gems to be set up so that the call to
`Gem.paths.home` works correctly. For that reason, it must
be included after `utils/gems` which is included in
`standalone/load_path` already.
2023-09-21 21:07:22 -07:00
Douglas Eichelberger
2969cdb5c1 Enable types in brew.rb 2023-03-18 13:55:19 -07:00
Mike McQuaid
2884b1649b
api: don't download files as root when Homebrew's not owned by root.
This was mentioned in a random comment. While we're here, make some
helper functions to query this a bit more nicely elsewhere when we do
it.
2023-02-23 10:04:50 +00:00
Mike McQuaid
fbdec8738d
Warn more when building from source
We warn sometimes when we tell people to build from source and it's
not supported but we don't actually warn non-developers when invoking
the various install commands so: let's start doing so.

While we're here, also update the existing messaging to reflect the fact
we're on Mastodon now too and we don't want maintainers being
individually bothered about errors either.

I've tried to balance having messages here vs. having them be so long
at the beginning of installation that they will be missed or be overly
obnoxious.
2023-02-17 16:10:38 +00:00
EricFromCanada
dfc9906184
internal messaging fixes 2023-02-10 23:17:16 -05:00
Rylan Polster
39097583b9
Set HOMEBREW_NO_INSTALL_FROM_API for certain commands 2023-02-06 16:17:04 +01:00
Mike McQuaid
46fc4f9f1b
Don't allow HOMEBREW_INSTALL_FROM_API when building from source
When either being in a non-default prefix or being on an unsupported
macOS version we expect most things to be built from source. In that
environment, do not allow HOMEBREW_INSTALL_FROM_API to be set.

Fixes #14475
2023-02-02 14:49:34 +00:00
Mike McQuaid
97def3c104
install: better error when using API and --HEAD.
- Tell people what to do to resolve this
- Tweak the instruction ordering to be consistent elsewhere
2023-01-26 11:08:56 +00:00
Mike McQuaid
46d727b475
HOMEBREW_INSTALL_FROM_API: various improvements.
- flip the messaging to refer to `HOMEBREW_NO_INSTALL_FROM_API` where relevant
- remove some duplicate checks
- better scope checks to just core tap formulae
2023-01-25 14:29:35 +00:00
apainintheneck
5708ed3171 Fix brew prof --stackprof
The `stackprof` gem wasn't being included
correctly because it was missing the path
directory. This vendored gems path is added
later on in `load_path.rb`.

We export the GEM_PATH and GEM_HOME environment
variables in setup_gem_environment! so we
can use that information if we require the
`rubygems` gem first.
2022-12-29 17:44:48 -08:00
Adrian Ho
a76451602d root auto-taps should be done as Homebrew user
Closes https://github.com/Homebrew/brew/issues/14263.
2022-12-19 18:06:09 +08:00
apainintheneck
c8f256b21d Cleanup brew prof
- Add exception in brew.rb require check for ruby-prof
2022-12-04 20:07:31 -08:00
Mike McQuaid
53b1c0f48e
Strengthen "don't create issues" language
We're still getting a non-trivial number of issues from configurations
we don't support and don't plan to.

Let people know that we know their experience will not be good and what
to expect if they file issues.

Co-authored-by: Eric Knibbe <enk3@outlook.com>
2022-10-20 11:39:20 +01:00
Bo Anderson
987abe7773
Prevent require executing some scripts 2022-09-08 01:44:31 +01:00
Rylan Polster
7ee35c6a0c
Allow developers to use dev commands and HOMEBREW_INSTALL_FROM_API 2022-09-06 12:59:13 -04:00
Mike McQuaid
e58d7d3456
brew: improve Docker detection.
Needed for Ubuntu 22.04.
2022-09-06 16:32:35 +01:00
Colin Dean
e7052fad0d Use heredoc for multiline error and store untapped official taps check
Review feedback on https://github.com/Homebrew/brew/pull/13581#pullrequestreview-1046232447
2022-07-21 13:24:23 -04:00
Colin Dean
5e56b9effe
Drops "cannot be retapped" from manual untap warning
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2022-07-21 11:51:21 -04:00
Colin Dean
ac53a6ae36 Instruct user to tap untapped official tap when running its commands
This came up in https://github.com/Homebrew/homebrew-bundle/issues/1108
wherein a user had unwittingly untapped some official taps that get
automatically tapped on first use and couldn't figure out why they
couldn't use the associated command.
2022-07-19 18:06:42 -04:00
Bo Anderson
02164a35db
Use ORIGINAL_PATHS over envs; reject nil PATH 2022-06-17 19:47:57 +01:00
Bo Anderson
fae972c9d7
brew.rb: remove 'nice' error message for missing envs 2022-06-17 19:47:56 +01:00
Bo Anderson
db8ab91429
Remove missing env retry mechanism 2022-06-17 19:47:55 +01:00
Rylan Polster
b896f6cb0d
Allow more developer commands with HOMEBREW_INSTALL_FROM_API 2022-06-16 21:31:15 -04:00
Rylan Polster
0c520844b4
Improve message 2022-02-11 10:49:21 -05:00
Phoenix Eliot
7a5eb3dbdb Fix rubocop warning 2022-02-08 12:14:00 -05:00
Phoenix Eliot
9e2c5910c5 Simplify 'brew cask' check 2022-02-08 12:08:32 -05:00
Phoenix Eliot
f18cbd2066 Add helpful error message when attempting to run brew cask 2022-01-11 14:17:03 -05:00
Mike McQuaid
11c5f8f05a
Improve discovery of some environment variables
There's a few bits of functionality that Homebrew has changed over the
years, makes sense as a sensible default but some people find really
annoying:

- automatically running `brew update`
- automatically running `brew cleanup`
- automatically upgrading outdated dependents
- automatically reinstalling broken dependents

For each of these: let's improve the documentation of the commands
whose behaviour is changed and the environment variables themselves.
2021-11-25 09:10:59 +00:00
Rylan Polster
249886f36f
Cleanup developer mode handling in brew.{sh,rb} 2021-10-26 01:29:15 -04:00
Rylan Polster
06b1e1f495
Improve messaging
Co-authored-by: Eric Knibbe <3324775+EricFromCanada@users.noreply.github.com>
2021-10-22 17:15:19 -04:00
Rylan Polster
0b8032d421
Document HOMEBREW_INSTALL_FROM_API 2021-10-22 12:37:57 -04:00
Bo Anderson
30b24cf4ad
Use HOMEBREW_CURL universally, including formulae 2021-10-04 02:03:04 +01:00
Bo Anderson
d4b88b1b55
brew.rb: remove gem setup for stackprof 2021-08-11 02:13:37 +01:00
Rylan Polster
27ba803bb5
Remove need for HOMEBREW_NO_DEV_CMD_MESSAGE 2021-07-20 11:47:31 -04:00
Rylan Polster
564a207bad
Add HOMEBREW_NO_DEV_CMD_MESSAGE 2021-07-19 10:06:38 -04:00
Rylan Polster
9f15432742
Fix tests 2021-07-17 14:08:38 -04:00