From a649d24e2a040e7b115f61b3117a03609ec252c3 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Fri, 17 Apr 2026 14:41:04 +0000 Subject: [PATCH] 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 Signed-off-by: Richard Lau --- src/node_file.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/node_file.cc b/src/node_file.cc index 7fb87639b37e96..d93f213202ec43 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1833,7 +1833,15 @@ static void RmSync(const FunctionCallbackInfo& 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);