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

*formulae: Avoid using rm_rf, rm_f or rmtree #177331

Closed
wants to merge 292 commits into from
Closed

Conversation

issyl0
Copy link
Member

@issyl0 issyl0 commented Jul 14, 2024

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

@issyl0 issyl0 added the CI-syntax-only Change only affects brew syntax, not the install. Only run syntax CI. label Jul 14, 2024
@github-actions github-actions bot added the long build Set a long timeout for formula testing label Jul 14, 2024
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks right!

@issyl0 issyl0 marked this pull request as ready for review July 14, 2024 18:22
@issyl0 issyl0 added this pull request to the merge queue Jul 14, 2024
Copy link
Member

@carlocab carlocab left a comment

Choose a reason for hiding this comment

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

We should probably be a bit more careful about the ones in post_install blocks, as those will be disruptive to more users.

Formula/c/ca-certificates.rb Show resolved Hide resolved
@issyl0 issyl0 removed this pull request from the merge queue due to a manual request Jul 14, 2024
@issyl0 issyl0 enabled auto-merge July 14, 2024 19:44
@fxcoudert
Copy link
Member

Two comments:

  • rm_f is often used to mean “delete if it exists”, which may cover a difference in linux/macOS build process.
  • I don't think this is just style issues, some of these may be breaking changes in formulas. We could bunch them in small batches, but they should be tested imho.

@Bo98
Copy link
Member

Bo98 commented Jul 15, 2024

For formulae, it might be an idea to just change rm_f to mean rm if File.exist?.

We do include FileUtils, but we can easily override that with a def rm_f because the formula API is our API, e.g.

module SafeFileUtils
  include FileUtils

  def rm_f(*)
    ...
  end
end

class Formula
  include SafeFileUtils

  ...
end

Which can be used in brew etc too. Or if we're not comfortable with that: then that flow could be used to odeprecated.

(Not saying we need to do this: just tabling options)

@issyl0 issyl0 disabled auto-merge July 15, 2024 02:23
@MikeMcQuaid
Copy link
Member

  • which may cover a difference in linux/macOS build process.

I think these differences should be covered with if/else instead.

For formulae, it might be an idea to just change rm_f to mean rm if File.exist?.

This would still be a breaking change. I think it'd be nicer to introduce a new method/API if we're going to do that rather than shadowing the FileUtils one.

@issyl0
Copy link
Member Author

issyl0 commented Jul 16, 2024

I re-generated this after the latest changes to the RuboCop.

@issyl0
Copy link
Member Author

issyl0 commented Jul 19, 2024

I don't think this is just style issues, some of these may be breaking changes in formulas. We could bunch them in small batches, but they should be tested imho.

Hmmm. I'll bunch these in smaller batches, and test installing and testing each one locally. :-)

@issyl0 issyl0 closed this Jul 19, 2024
@issyl0 issyl0 deleted the rubocop-fix-rmrf-usage branch July 19, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-syntax-only Change only affects brew syntax, not the install. Only run syntax CI. long build Set a long timeout for formula testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants