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

process.loadEnvFile() error message issue: Failed to load '%s' #52463

Closed
hyrious opened this issue Apr 11, 2024 · 1 comment · Fixed by #52438
Closed

process.loadEnvFile() error message issue: Failed to load '%s' #52463

hyrious opened this issue Apr 11, 2024 · 1 comment · Fixed by #52438
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core.

Comments

@hyrious
Copy link

hyrious commented Apr 11, 2024

Version

v21.7.2

Platform

Darwin MAGIT00999.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:11:05 PDT 2024; root:xnu-10063.101.17~1/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

Run the command at somewhere without a .env file.

$ node -p 'process.loadEnvFile()'

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

No response

What do you see instead?

node:internal/process/per_thread:265
      _loadEnvFile();
      ^

Error: ENOENT: .env, Failed to load '%s'.

Additional information

This is because someone wronly used ThrowUVException:

case dotenv.ParseResult::FileError: {
env->ThrowUVException(UV_ENOENT, "Failed to load '%s'.", path.c_str());
break;

Maybe this patch would work:

    case dotenv.ParseResult::FileError: {
-     env->ThrowUVException(UV_ENOENT, "Failed to load '%s'.", path.c_str());
+     env->ThrowUVException(UV_ENOENT, "read", nullptr, path.c_str());
      break;
    }
@targos targos linked a pull request Apr 11, 2024 that will close this issue
@targos
Copy link
Member

targos commented Apr 11, 2024

#52438 is fixing this

@VoltrexKeyva VoltrexKeyva added the errors Issues and PRs related to JavaScript errors originated in Node.js core. label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants