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

Formula-Cookbook: Stop recommending rm_f in postinstall #17965

Merged
merged 1 commit into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ Style/RedundantRegexpArgument:
# Want to be able to display partial formulae in the docs.
Style/TopLevelMethodDefinition:
Enabled: false

# Formulae and Casks no longer use `rm_f`/`rm_rf`, so the docs need to match.
Lint/NonAtomicFileOperation:
Copy link
Member

Choose a reason for hiding this comment

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

Ideally we'd keep this around for mkdir_p.

Is this disabled/enabled in the other Homebrew .rubocop.yml file(s)? If so: should it be adjusted there too?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's enabled by default. But it only complained about this one when I removed the f.

Copy link
Member

Choose a reason for hiding this comment

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

I think that's because this is a non-atomic operation now. Particularly in post-install where we don't fully control the location: this is potentially problematic.

See: https://docs.rubocop.org/rubocop/cops_lint.html#lintnonatomicfileoperation

I think having this still enabled for mkdir_p but also having this be consistent everywhere would be desirable if possible.

Enabled: false
2 changes: 1 addition & 1 deletion docs/Formula-Cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ class Foo < Formula
url "https://example.com/foo-1.0.tar.gz"

def post_install
rm_f pkgetc/"cert.pem"
rm pkgetc/"cert.pem" if File.exist?(pkgetc/"cert.pem")
pkgetc.install_symlink Formula["ca-certificates"].pkgetc/"cert.pem"
end
# ...
Expand Down