101 Commits

Author SHA1 Message Date
Douglas Eichelberger
fb6c51da07
Enable strict typing in SystemCommand 2025-09-02 10:26:40 -07:00
Sam Ford
ba0bc88b3d
AbstractUninstall: coerce which argument to String
`Cask::Artifact::AbstractUninstall.uninstall_script` contains a
`which` call that uses a `Pathname` argument instead of a `String` and
this leads to a type error (`Parameter 'cmd': Expected type String,
got type Pathname with value...`). This resolves the error by calling
`#to_s` on the `executable_path` argument.
2025-08-28 11:21:57 -04:00
Eric Knibbe
12e4c8a05e
sync output of sudo messaging 2025-08-16 00:57:59 -04:00
Carlo Cabrera
7cd1972f39
Revert "cask/artifact/abstract_uninstall: fix trash_paths" 2025-05-14 01:39:47 +08:00
Patrick Linnane
c6a2fa335d
brew style --fix 2025-05-05 14:35:08 -07:00
Carlo Cabrera
f816a39d1f
cask/artifact/abstract_uninstall: fix trash_paths
This is currently behaving incorrectly when calling `trash.swift` fails
due to lack of permissions. In this instance, `trash.swift` prints

    error: permissionDenied

to stdout, and this is incorrectly parsed as having successfully trashed
a file named `error` and another named ` permissionDenied`.

Let's fix this by ensuring that:
- any paths in `trashed` are in the `paths` that we wanted to trash in
  the first place
- define `untrashable` by removing the `trashed` paths from `paths`
2025-04-24 18:03:07 +08:00
Sean Molenaar
27a2d94c48 feat: allow zap on linux 2025-02-17 14:30:44 +01:00
apainintheneck
ebede56314 cask/artifact/abstract_uninstall: handle sudo trashed paths correctly
This showed a confusing message when the trash path was able to be
deleted using sudo since the untrashable array was updated but
the check was higher up for returning early.

```
==> Trashing files:
/Users/Shared/Maxon
/Users/Shared/Red Giant
~/Library/Application Support/Maxon
~/Library/Application Support/Red Giant
~/Library/Caches/net.maxon.app-manager
~/Library/Preferences/Maxon
~/Library/Preferences/net.maxon.app-manager.plist
~/Library/Saved Application State/net.maxon.app-manager.savedState
==> Using sudo to gain ownership of path '/Users/Shared/Maxon'
==> Using sudo to gain ownership of path '/Users/Shared/Red Giant'
Warning: The following files could not be trashed, please do so manually:
==> Removing all staged versions of Cask 'maxon'
```

The warning about files not getting trashed should only be shown if
some files didn't get trashed.

Fixes https://github.com/Homebrew/brew/issues/18901
2024-12-08 15:53:59 -08:00
Bo Anderson
7308c105a4
cask: try fix a couple of permission edge cases under multi-user 2024-11-25 17:36:47 +00:00
Patrick Linnane
c2e2b23c50
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-10-02 10:03:12 -07:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Bo Anderson
fa00d2a9fd
cask: fix trash.swift under Xcode 16 2024-06-15 03:09:50 +01:00
Mike McQuaid
6e9288470e
brew style --fix 2024-05-23 17:15:43 +01:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Mike McQuaid
8baed211a7
brew style --fix 2024-04-08 19:23:33 +01:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Issy Long
f4218a6316
Fix RuboCop Performance/MapCompact offenses
- Rename an iterator variable since it would make the line too long.
2024-02-25 22:59:59 +00:00
Douglas Eichelberger
eb7c3e52a0 Require SystemInclude only where needed 2024-01-31 11:42:01 -08:00
Douglas Eichelberger
f6c7eb7124 Add hash/keys to extend/ 2024-01-19 13:36:17 -08:00
Mike McQuaid
228b1d62ed
cask/artifact/abstract_uninstall: handle signal failures.
If the process is running as another user: this will always fail.
2023-12-20 19:43:46 +00:00
Patrick Linnane
9dee80cb2d
various: fix style errors 2023-12-18 09:34:01 -08:00
Mike McQuaid
eb1355e624
Add HOMEBREW_SUDO_THROUGH_SUDO_USER
This environment variable allows telling Homebrew to use the `SUDO_USER`
variable to `sudo` through that user when Homebrew (Cask) attempts to
run `sudo`.

While we're here, clarify in some messaging that we're running `sudo`
and that that's the password we're asking for; the specific password is
configuration dependent and not the specific password for the user.

Similarly, remove the `Package installers may write to any location`
output; it's kinda spammy and doesn't feel like the right place.
2023-09-29 18:49:44 +01:00
Bo Anderson
af7d744af0
Fixes for Ruby 3 2023-09-29 05:25:48 +01:00
Markus Reiter
935c5efaf8
Use sudo for rmdir if necessary. 2023-05-13 06:46:59 +02:00
Mike McQuaid
0e387fee8c
Merge pull request #15138 from JBYoshi/cask-move-contents
Don't remove cask directories when upgrading.
2023-05-04 11:43:44 +01:00
Ilya Kulakov
476d97934f sudo: change sudo_user to sudo_as_root. 2023-04-28 11:22:54 -07:00
Ilya Kulakov
d470661b37 sudo: add the sudo_user arg to SystemCommand. 2023-04-28 11:11:53 -07:00
Ilya Kulakov
563387a7b4 sudo: explicitly specify the root user where necessary
With sudoers one may override default sudo user. This mostly works
provided the admin configured the replacement appropriately. However
there are exceptions that absolutely must be run by root such as
/usr/sbin/installer and, under certain circumstances, /bin/launchctl.
2023-04-28 11:11:53 -07:00
JBYoshi
a1571702d3
Merge remote-tracking branch 'origin/master' into cask-move-contents 2023-04-25 15:44:29 -05:00
Douglas Eichelberger
08af78a2a5 brew style --fix 2023-04-25 09:26:24 -07:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
JBYoshi
f97bce040f
Update for feedback. 2023-04-24 10:50:01 -05:00
JBYoshi
9fedaee462
Only keep empty directories when the new version also has them. 2023-04-08 16:13:12 -05:00
JBYoshi
dcc4ae76e8
Also keep app directories with "brew reinstall". 2023-04-04 11:36:27 -05:00
Douglas Eichelberger
4dcd5ac47f Remove HashValidator 2023-03-19 17:37:58 -07:00
Douglas Eichelberger
516c61057b Use ActiveSupport Hash#assert_valid_keys instend of refinement 2023-03-19 17:37:58 -07:00
Ruoyu Zhong
e9ce4a5a4e
Update path to system settings on Ventura
"System Preferences" has been renamed to "System Settings" on Ventura.
Privacy and security settings have moved, too. This commit makes sure
these changes are reflected. (Some adjustments were already made in
#14092.)

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2023-03-17 19:24:07 +08:00
Douglas Eichelberger
900ee97f95 Revert splat changes to AbstractUninstall 2023-03-07 06:46:59 -08:00
Douglas Eichelberger
d98b7845d3 Enable typing in misc files 2023-03-03 08:29:26 -08:00
apainintheneck
c19017c6bd Make Cask#to_h work without the API
Set metadata when we load casks from the source API.

Set `@tap_git_head` manually.

Also, allow `auto_update` to receive false.
This is only done for consistency.

Stop double printing the `kext` caveat.

Handle Array elements correctly when substituting
path elements in artifacts. This affected how the
Uninstall Signal keys were evaluated (they are
represented as arrays of arrays).
2023-02-28 19:36:20 -08:00
Douglas Eichelberger
29c6baeed1 Enable typing in Cask::Artifact 2023-02-22 09:11:29 -08:00
Bevan Kay
3869bf156c
change line splitting method 2022-12-29 12:54:59 +11:00
Bevan Kay
db9d48a7ec
fix tests 2022-12-28 12:50:16 +11:00
Bevan Kay
2614a29419
fix style 2022-12-19 14:43:16 +11:00
Bevan Kay
84f288be79
fix style 2022-12-19 14:39:48 +11:00
Bevan Kay
1ddd130ef9
add comment to .drop(), don't add blank lines to services array 2022-12-19 14:35:20 +11:00
Bevan Kay
e8e6ee30b4
add initial tests 2022-12-13 00:00:43 +11:00
Bevan Kay
836efe621f
cask/artifiact/abstract_uninstall: allow wildcard entries for launchctl 2022-12-05 15:08:23 +11:00
Bevan Kay
33d3a5d728
cask/artifiact/abstract_uninstall: allow wildcard entries for launchctl 2022-11-09 13:21:49 +11:00
Bo Anderson
eac32f0b20
Additional fixes for Ruby 3 compatibility 2022-10-18 01:54:59 +01:00