skylot/jadx · warning · JadxRuntimeException

Failed to delete directory ${dir}

Error message

Failed to delete directory ${dir}

What it means

Thrown by the private deleteDir(Path, boolean) when Files.walkFileTree fails to traverse the directory tree. The traversal itself throws if the root directory does not exist, or if a permission issue prevents visiting files/directories. Individual file and subdirectory delete failures during the walk are logged as warnings (LOG.warn) and do NOT throw — only the walkFileTree failure itself triggers this exception. The message includes the root dir path.

Source

Thrown at jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java:223

					} catch (Exception e) {
						LOG.warn("Failed to delete file {}", path.toAbsolutePath(), e);
					}
				});
			}
			// after all files are deleted, remove empty directories
			if (keepRootDir) {
				// root dir always last
				ListUtils.removeLast(directories);
			}
			for (Path directory : directories) {
				try {
					Files.delete(directory);
				} catch (IOException e) {
					LOG.warn("Failed to delete directory {}", directory.toAbsolutePath(), e);
				}
			}
		} catch (Exception e) {
			throw new JadxRuntimeException("Failed to delete directory " + dir, e);
		}
	}

	public static void clearTempRootDir() {
		if (Files.isDirectory(tempRootDir)) {
			clearDir(tempRootDir);
		}
	}

	public static void clearDir(Path clearDir) {
		try {
			deleteDir(clearDir, true);
		} catch (Exception e) {
			throw new JadxRuntimeException("Failed to clear directory " + clearDir, e);
		}
	}

	/**

View on GitHub (pinned to e738a26571)

Solutions

  1. Guard with existence check: only call deleteDir if Files.exists(dir).
  2. Use the more lenient deleteDirIfExists(Path) variant which catches exceptions internally and logs them.
  3. Check directory readability and execute permissions before deletion.
  4. Inspect the cause: NoSuchFileException means already gone; AccessDeniedException means a permission problem.

Example fix

// before
FileUtils.deleteDir(tempDir);

// after
if (Files.exists(tempDir)) {
    FileUtils.deleteDir(tempDir);
}
Defensive patterns

Strategy: fallback

Validate before calling

public static boolean isDeletableDir(Path dir) {
    return Files.exists(dir) && Files.isReadable(dir);
}

Try / catch

try {
    FileUtils.deleteDir(dir);
} catch (JadxRuntimeException e) {
    if (e.getCause() instanceof NoSuchFileException) {
        // already gone — not an error
        return;
    }
    LOG.warn("could not delete dir {}: {}", dir, e.getCause().getMessage());
}

Prevention

When it happens

Trigger: Calling deleteDir on a path that does not exist (NoSuchFileException from walkFileTree). Calling it on a directory where the process lacks permission to read or enter subdirectories. A broken symlink or filesystem error during tree traversal.

Common situations: Attempting to clean up a temp directory that was already removed by another process or a prior cleanup pass. Permission denied because files inside were created by a different user. Network filesystem errors during traversal. Circular symlinks causing traversal issues (though FOLLOW_LINKS is not used here, so less likely).

Related errors


AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14). Data as JSON: /api/errors/2a45d71a5f404e5f. Report an issue: GitHub.