130 Commits

Author SHA1 Message Date
Mike McQuaid
ba6ec7066b
Revert "Revert "Enable HOMEBREW_AUTOREMOVE by autoremove_default"" 2024-05-26 15:39:45 +01:00
Carlo Cabrera
ffd6c1f5c3
Revert "Enable HOMEBREW_AUTOREMOVE by autoremove_default"
`autoremove` is destructive, and it can be difficult for users to
recover from it occuring when they weren't expecting it.

Fixes #17363
Fixes Homebrew/discussions#5395

This reverts commit 3d114161b3c3f1a95b94e8530f5bc45bb44bbbd9.
This reverts commit efb14a0ec264c4ef408dbbd5330905dd230e979c.
2024-05-25 23:19:42 +08:00
apainintheneck
efb14a0ec2 fix no autoremove suggestion typo
This suggests setting an environment variable that is different
than the one we end up checking so I've updated the warning so
now things match. If the goal was to have the name in the warning,
the environment variable checking logic could be updated. I have
no personal preference.

```console
$ brew irb
==> Interactive Homebrew Shell
Example commands available with: `brew irb --examples`
brew(main):001:0> ENV["HOMEBREW_NO_AUTO_REMOVE"] = "1"
=> "1"
brew(main):002:0> Homebrew::EnvConfig.no_autoremove?
=> false
brew(main):003:0> ENV["HOMEBREW_NO_AUTOREMOVE"] = "1"
=> "1"
brew(main):004:0> Homebrew::EnvConfig.no_autoremove?
=> true
```
2024-05-09 20:14:16 -07:00
Mike McQuaid
3d114161b3
Enable HOMEBREW_AUTOREMOVE by autoremove_default
Enabled `HOMEBREW_AUTOREMOVE` by default, and added
`HOMEBREW_NO_AUTOREMOVE` to disable it.

Co-authored-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2024-05-09 13:47:52 +01:00
Douglas Eichelberger
4cf9ef831a Port Homebrew::Cmd::Uninstall 2024-04-01 11:46:01 -07:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
hyuraku
db328b59f2 move cask/cmd/uninstall to cask/uninstall 2023-03-09 22:33:29 +09:00
hyuraku
ed2c1d3716 repair cmd/uninstall with zap option 2023-03-06 22:27:53 +09:00
apainintheneck
fe83500617 Moved autoremove logic into cleanup.rb and formula.rb
Cleanup.rb:
- Added #autoremove method
- #autoremove is called in clean when HOMEBREW_AUTOREMOVE is set

Formula.rb:
- Added #unused_formulae_with_no_dependents and helpers

Removed old autoremove.rb module.
2022-07-14 13:16:26 -07:00
apainintheneck
fa43418bfb Moved autoremove logic into autoremove.rb
This allows us to call that logic internally in other brew
commands instead of having to shell out.
2022-07-13 16:31:41 -07:00
apainintheneck
74f1eca14c autoremove.rb: moved logic out into formula.rb, and uninstall.rb
This allows us to autoremove formulae in the autoremove and
uninstall commands without having to shell out to brew.
2022-07-13 16:28:49 -07:00
apainintheneck
f8ae5f3bc4 cmd/uninstall: Add env variable that runs autoremove after uninstalls
When HOMEBREW_UNINSTALL_AUTOREMOVE is set, `brew autoremove` is run
after every successful call to `brew uninstall`.
2022-07-13 16:28:49 -07:00
Mike McQuaid
2d5eab2e1c
brew style --fix 2022-06-30 08:56:21 +01:00
Seeker
880a82d21a
uninstall: delete references to unused --binaries flag 2021-02-22 19:48:43 -08:00
nandahkrishna
7965ad6160
cmd/uninstall: check for dependent casks 2021-02-09 08:47:11 +05:30
EricFromCanada
2ae4f11963 reorder command flags 2021-01-26 15:36:44 -05:00
Rylan Polster
d1f3e39b7b
Update commands to generate usage banner 2021-01-18 21:20:11 -05:00
Dawid Dziurla
332372469f
cmd: indicate multiple named args in usage banner 2021-01-15 13:04:00 +01:00
Rylan Polster
da811373d3 Add named_args DSL for commands 2021-01-13 17:09:42 -05:00
hyuraku
0a97cd18a5 set default args 2020-12-17 21:14:18 +09:00
hyuraku
7be216fcbe change function name 2020-12-17 21:07:43 +09:00
hyuraku
d7f9bb6247 add function to define path 2020-12-17 21:07:43 +09:00
Markus Reiter
1b9002c04a Fix type errors in postinstall. 2020-11-29 21:23:54 +01:00
Markus Reiter
2c47678b05 Add --zap flag to brew uninstall and remove brew zap. 2020-11-19 15:07:59 +01:00
Markus Reiter
f4b4fdac98 Add brew zap command. 2020-11-19 13:42:02 +01:00
Markus Reiter
5097af3b74 Support --cask flag in brew uninstall. 2020-11-18 17:30:34 +01:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
Tie
afd7bb8889 make suggestions 2020-11-05 12:27:22 -05:00
Tie
30a3561448 move uninstall logic to new file 2020-11-04 16:45:52 -05:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Misty De Meo
c06848c487
Fix printing MultipleVersionsInstalledError details
The refactor in 6e8f5d0958247e4b4d629866099ed2836a0e0863 means that the
exception no longer exposes the name of the package with multiple versions,
and as a result the rescuer is unable to print this information.

Because we now have a path in which MultipleVersionsInstalledError doesn't
have the name at all, we can't reasonably restore the old behaviour.
And since rack resolution happens purely internal to the function that
raises the exception, the caller has no way to know what name to use.
However, since the exception text gets printed anyway, we can just move
this text into the exception itself.

Fixes the following error:

```
Error: mpd has multiple installed versions
Error: undefined method `name' for #<MultipleVersionsInstalledError:0x00007fc6009d8870>
/usr/local/Homebrew/Library/Homebrew/cmd/uninstall.rb:137:in `rescue in uninstall'
/usr/local/Homebrew/Library/Homebrew/cmd/uninstall.rb:135:in `uninstall'
/usr/local/Homebrew/Library/Homebrew/brew.rb:119:in `<main>'
```
2020-09-09 11:56:53 -07:00
William Ma
fa7bd3bff6 args: Migrate usage of args loading methods to args.named 2020-08-23 09:02:20 -04:00
Markus Reiter
b48bc316e0 Use CLI::Parser for cask commands. 2020-08-13 05:15:15 +02:00
Markus Reiter
8a32954940 Move cask/all to just cask. 2020-08-09 01:34:07 +02:00
William Ma
907d4d7f74 Add shared methods for uninstalling, reinstalling casks 2020-08-05 11:04:40 -04:00
Markus Reiter
d4c2ffd705 Refactor CLI::Parser. 2020-07-31 15:07:17 +02:00
Markus Reiter
e14506e589 Pass args in uninstall instead of using global args. 2020-07-30 03:21:12 +02:00
Markus Reiter
c0d42dd922 Remove --force from global_options. 2020-07-28 10:31:11 +02:00
William Ma
525d1ac27d Fix PR issues 2020-07-03 10:33:38 -04:00
William Ma
1826be81f2 style: Replace Hash.new with {} 2020-07-02 15:29:58 -04:00
William Ma
eb1ea006f2 uninstall: Refactor when using --force 2020-07-02 15:28:41 -04:00
William Ma
72dcbd6fda style: Dedent cask uninstall block 2020-06-30 13:43:45 -04:00
William Ma
dff61c9eab style: Fix style issues 2020-06-30 12:21:21 -04:00
William Ma
8a05b5258a args: Refactor to load casks directly 2020-06-30 12:08:03 -04:00
William Ma
e733fa16a2 uninstall: Refactor to use AbstractCommand instead of declaring a class method 2020-06-24 15:08:42 -04:00
William Ma
90c26dadc7 uninstall: Add ability to reference casks from brew uninstall 2020-06-24 11:59:55 -04:00
skim
bb27478de0
fixes uninstall if formula is unavailable 2020-05-13 17:56:36 -07:00
Mike McQuaid
a3474e8361
uninstall: tweak paths array logic. 2020-05-10 19:22:54 +01:00
Mike Fiedler
e4823ea6fe
cmd/uninstall: fix Array comparison
In #7526 a comparison for `paths` was introduced, but if `paths` is ever
`nil`, this triggers an error.

Coercing the variable to an Array should alleviate this problem, as
`nil.to_a` produces an empty and comparable Array.

Fixes #7540

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
2020-05-10 11:28:42 -04:00