skylot/jadx · error · JadxRuntimeException

Failed to update temp root directory

Error message

Failed to update temp root directory

What it means

Thrown when FileUtils.updateTempRootDir fails to switch jadx's temp directory to a user-specified location. The method first calls makeDirs(newTempRootDir) (which can itself throw 'Can't create directory'), then Files.createTempDirectory inside it. A failure means either the target directory cannot be created/validated, or a unique temp subdirectory cannot be allocated within it.

Source

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

	public static final String JADX_TMP_INSTANCE_PREFIX = "jadx-instance-";
	public static final String JADX_TMP_PREFIX = "jadx-tmp-";

	private static Path tempRootDir = createTempRootDir();

	private FileUtils() {
		// utility class
	}

	public static synchronized Path updateTempRootDir(Path newTempRootDir) {
		try {
			makeDirs(newTempRootDir);
			Path dir = Files.createTempDirectory(newTempRootDir, JADX_TMP_INSTANCE_PREFIX);
			tempRootDir = dir;
			dir.toFile().deleteOnExit();
			return dir;
		} catch (Exception e) {
			throw new JadxRuntimeException("Failed to update temp root directory", e);
		}
	}

	private static Path createTempRootDir() {
		try {
			Path dir = Files.createTempDirectory(JADX_TMP_INSTANCE_PREFIX);
			dir.toFile().deleteOnExit();
			return dir;
		} catch (Exception e) {
			throw new JadxRuntimeException("Failed to create temp root directory", e);
		}
	}

	public static List<Path> listFiles(Path dir) {
		try (Stream<Path> files = Files.list(dir)) {
			return files.collect(Collectors.toList());
		} catch (IOException e) {
			throw new JadxRuntimeException("Failed to list files in directory: " + dir, e);

View on GitHub (pinned to e738a26571)

Solutions

  1. Verify the candidate directory is writable before calling: Files.isWritable(newTempRootDir).
  2. Ensure the parent path chain exists: Files.createDirectories(newTempRootDir).
  3. Avoid pointing the temp root at a file or a symlink to a non-directory.
  4. Check the JadxRuntimeException cause to distinguish mkdir failure from createTempDirectory failure.

Example fix

// before
FileUtils.updateTempRootDir(customTempDir);

// after
Files.createDirectories(customTempDir);
if (!Files.isWritable(customTempDir)) throw new IllegalStateException("temp dir not writable");
FileUtils.updateTempRootDir(customTempDir);
Defensive patterns

Strategy: validation

Validate before calling

public static boolean isTempDirCandidate(Path dir) {
    if (!Files.exists(dir)) {
        try { Files.createDirectories(dir); } catch (IOException e) { return false; }
    }
    return Files.isDirectory(dir) && Files.isWritable(dir);
}

Try / catch

try {
    FileUtils.updateTempRootDir(customTempDir);
} catch (JadxRuntimeException e) {
    LOG.error("Cannot use temp dir {}: {}", customTempDir, e.getCause().getMessage());
    // fall back to default
}

Prevention

When it happens

Trigger: Calling FileUtils.updateTempRootDir(Path) where the path is read-only, the parent doesn't exist, disk is full, or the path points to a file instead of a directory. Also if makeDirs internally fails because mkdirs() returns false and isDirectory() is false.

Common situations: User sets -Djava.io.tmpdir or a jadx-specific temp dir option to a path on a read-only filesystem. Running in a sandboxed/containerized environment where the specified temp root is not writable. The path was valid at config time but a parent mount was removed before the call.

Related errors


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