NationalSecurityAgency/ghidra · critical · IOException
Failed to find the module's jython-src directory
Error message
Failed to find the module's jython-src directory
What it means
Thrown by JythonUtils.setupJythonCacheDir() when the module's jython-src directory cannot be found. It first checks <moduleRoot>/jython-src, and if absent tries Application.getModuleDataSubDirectory(moduleName, 'jython-src'); a FileNotFoundException from that lookup triggers this IOException. The source .py files to seed the cache are therefore missing.
Source
Thrown at Ghidra/Extensions/Jython/src/main/java/ghidra/jython/JythonUtils.java:89
if (!FileUtilities.mkdirs(cacheDir)) {
throw new IOException("Failed to create the jython cache directory at: " + cacheDir);
}
File jythonSrcDestDir = new File(cacheDir, JYTHON_SRC);
if (!FileUtilities.createDir(jythonSrcDestDir)) {
throw new IOException(
"Failed to create the " + JYTHON_SRC + " directory at: " + jythonSrcDestDir);
}
File jythonModuleDir = Application.getMyModuleRootDirectory().getFile(false);
File jythonSrcDir = new File(jythonModuleDir, JYTHON_SRC);
if (!jythonSrcDir.exists()) {
try {
jythonSrcDir = Application.getModuleDataSubDirectory(jythonModuleDir.getName(),
JYTHON_SRC).getFile(false);
}
catch (FileNotFoundException e) {
throw new IOException("Failed to find the module's " + JYTHON_SRC + " directory");
}
}
try {
FileUtilities.copyDir(jythonSrcDir, jythonSrcDestDir, f -> f.getName().endsWith(".py"),
monitor);
}
catch (IOException e) {
throw new IOException(
"Failed to copy " + JYTHON_SRC + " files to: " + jythonSrcDestDir);
}
System.setProperty("python.cachedir.skip", "false");
System.setProperty("python.cachedir", cacheDir.getAbsolutePath());
System.setProperty("python.path", jythonSrcDestDir.getAbsolutePath());
return cacheDir;
}View on GitHub (pinned to d5f144c24d)
Solutions
- Reinstall/repair the Jython extension so its module data contains jython-src.
- In dev mode, run the module data build/copy task to populate jython-src under the module.
- Confirm Application.getMyModuleRootDirectory() points at the Jython module and that its data subdirectory is intact.
Example fix
null
Defensive patterns
Strategy: validation
Validate before calling
import java.io.File;
File moduleRoot = Application.getMyModuleRootDirectory().getFile(false);
File src = new File(moduleRoot, "jython-src");
if (!src.exists()) {
// module data missing jython-src; repair/extend before interpreter init
} Type guard
null
Try / catch
try {
GhidraJythonInterpreter.get();
} catch (NullPointerException npe) {
// get() swallowed the IOException and returned null; verify module data
} Prevention
- Reinstall the Jython extension with its full data tree.
- Run the dev build task that copies jython-src into module data.
- Confirm Application.getMyModuleRootDirectory() resolves to the Jython module.
When it happens
Trigger: Interpreter init where the Jython extension module data did not include the jython-src tree — e.g. a partial install where jython-2.7.4 home exists but the source bundle was not laid down, or a dev build that skipped copying jython-src.
Common situations: Trimmed/custom distribution that shipped the Jython home but not jython-src; a module layout change after upgrade; an extension rebuild that omitted the data copy step.
Related errors
- Failed to find the jython home directory at: {jythonHomeDir}
- Cannot find Python source for {name}. If this is a remote s
- Failed to create the jython cache directory at: {cacheDir}
- Failed to create the jython-src directory at: {jythonSrcDest
- Failed to copy jython-src files to: {jythonSrcDestDir}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/967fc3d8e7f7b7f2.
Report an issue: GitHub.