Skip to content

Fix error handling when looking for configuration files #6676

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

Merged

Conversation

yannayl
Copy link
Contributor

@yannayl yannayl commented Feb 3, 2025

What's the problem this PR addresses?

When looking for configuration files if reading a candidate throws an exception the exception is not caught and the user gets a cryptic and non-informative message. e.g. if you happen to have a directory named .yarnrc.yml in the root of your project every yarn command will result with this message:

Internal Error: EISDIR: illegal operation on a directory, read
Error: EISDIR: illegal operation on a directory, read

which doesn't include the file.

How did you fix it?

This change moves the reading operation into the try clause and handles read errors in the same way parsing errors are handled.

Checklist

I did it from GH online editor so I can't run stuff. Sorry.
Hopefully someone can pick it up it would save the next poor soul a few hours.

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

yannayl and others added 3 commits February 3, 2025 07:26
When looking for configuration files if reading a candidate throws an exception the exception is not caught and the user gets a cryptic and non-informative message.
e.g. if you happen to have a directory named `.yarnrc.yml` in the root of your project every yarn command will result with this message:
```
Internal Error: EISDIR: illegal operation on a directory, read
Error: EISDIR: illegal operation on a directory, read
```
which doesn't include the file.

This change moves the reading operation into the try clause and handles read errors in the same way parsing errors are handled.
@arcanis arcanis merged commit 0208e4e into yarnpkg:master Feb 14, 2025
26 checks passed
@yannayl yannayl deleted the fix-configuration-file-read-error-handling branch February 15, 2025 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants