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

Change load error messages to use Kernel#warn instead of $stderr.puts #48777

Merged
merged 1 commit into from Jul 20, 2023

Conversation

paracycle
Copy link
Contributor

Motivation / Background

This Pull Request has been created because the current method of printing directly to $stderr for load errors can be unnecessarily noisy.

When development tools try to load Rails components, they sometimes end up loading files that will error out since a dependency is missing. In these cases, the tooling can catch the error and change its behaviour, but not suppress the message as easily.

Since the warning is printed directly to $stderr, the tooling has to swap the stderr around to be able to suppress these messages, which is a quite finicky thing to do.

This change makes Rails print these warnings using Kernel#warn instead, which can be quite easily suppressed by any tooling.

Detail

This Pull Request changes the way load error messages are printed from using $stderr.puts to Kernel#warn.

Additional information

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

…uts`

When development tools try to load Rails components, they sometimes end up loading files that will error out since a dependency is missing. In these cases, the tooling can catch the error and change its behaviour.

However, since the warning is printed directly to `$stderr`, the tooling cannot catch and suppress it easily, which ends up causing noise in the output of the tool.

This change makes Rails print these warnings using `Kernel#warn` instead, which can be suppressed by the tooling.
@guilleiguaran guilleiguaran merged commit bb599f5 into rails:main Jul 20, 2023
9 checks passed
@dogweather
Copy link
Contributor

Thanks @guilleiguaran for the fast merge!

@casperisfine casperisfine deleted the uk-use-kernel-warn-for-warnings branch July 24, 2023 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants