src: workaround AIX libc++ std::filesystem bug

On AIX libc++ is returning `EEXIST` instead of `EACCES` when using
`std::filesystem::remove_all()` without appropriate permissions to
recursively remove the directory.

Co-authored-by: Abdirahim Musse <abdirahim.musse@ibm.com>
Signed-off-by: Richard Lau <richard.lau@ibm.com>
PR-URL: https://github.com/nodejs/node/pull/62788
Refs: https://github.com/nodejs/node/issues/62790
Reviewed-By: Abdirahim Musse <abdirahim.musse@ibm.com>
Reviewed-By: Stewart X Addison <sxa@redhat.com>
This commit is contained in:
Richard LauandAbdirahim Musse authored and Antoine du Hamel committed 2026-05-07 15:41:31 +02:00
1 parent 7597d204c1
commit ad9a2909c2
1 file changed
+8
+8
View File
@@ -1737,7 +1737,15 @@ static void RmSync(const FunctionCallbackInfo<Value>& args) {
} else if (error == std::errc::not_a_directory) {
std::string message = "Not a directory: " + file_path_str;
return env->ThrowErrnoException(ENOTDIR, "rm", message.c_str(), path_c_str);
#ifdef _AIX
} else if (error == std::errc::permission_denied ||
error == std::errc::file_exists) {
// Workaround for clang libc++ bug on AIX: std::filesystem::remove_all()
// incorrectly returns EEXIST (17) instead of EACCES (13) for permission
// errors when trying to remove directories without proper permissions.
#else
} else if (error == std::errc::permission_denied) {
#endif
std::string message = "Permission denied: " + file_path_str;
return env->ThrowErrnoException(
permission_denied_error, "rm", message.c_str(), path_c_str);