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;
}
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
.envfile.$ 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?
Additional information
This is because someone wronly used
ThrowUVException:node/src/node_process_methods.cc
Lines 494 to 496 in 5bae73d
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; }