juicedata/juicefs · critical · RuntimeException
StubLoader load failed
Error message
StubLoader load failed
What it means
Before loading the native library, the client runs StubLoader, which extracts/loads the bundled native stub and records any failure cause. If a failure cause is still set after initStubLoader(), this RuntimeException wraps it, meaning the bundled native library could not be loaded into the JVM.
Source
Thrown at sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java:786
try {
Thread.interrupted();
Method load = clazz.getDeclaredMethod("load");
load.setAccessible(true);
load.invoke(null);
Field loaded = clazz.getDeclaredField("loaded");
loaded.setAccessible(true);
loaded.set(null, true);
Field failureCause = clazz.getDeclaredField("failureCause");
failureCause.setAccessible(true);
failureCause.set(null, null);
} catch (Throwable e) {
}
}
if (StubLoader.getFailureCause() != null) {
throw new RuntimeException("StubLoader load failed", StubLoader.getFailureCause());
}
}
public static Libjfs loadLibrary() {
initStubLoader();
LibraryLoader<Libjfs> libjfsLibraryLoader = LibraryLoader.create(Libjfs.class);
libjfsLibraryLoader.failImmediately();
String osId = "so";
String archId = "amd64";
String resourceFormat = "libjfs-%s.%s.gz";
String nameFormat = "libjfs-%s.%s.%s";
File dir = new File("/tmp");
String os = System.getProperty("os.name");
String arch = System.getProperty("os.arch");
if (arch.contains("aarch64")) {View on GitHub (pinned to c9a67b23e8)
Solutions
- Read StubLoader.getFailureCause() (shown as the cause) — it names the real load problem.
- Confirm the OS/arch has a bundled build; use STATIC=1 or a musl-compatible build on Alpine.
- Clear the stale extracted library in java.io.tmpdir and retry.
- Ensure the temp directory is writable and TMPDIR points somewhere valid; install missing shared libraries (ldd on the extracted .so).
Example fix
# before: failure extracting to /tmp (read-only) TMPDIR=/tmp java ... // after TMPDIR=/var/tmp java ... # or fix /tmp permissions
Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: confirm temp dir is writable
java.io.File tmp = new java.io.File(System.getProperty("java.io.tmpdir"));
if (!tmp.canWrite()) throw new IllegalStateException("TMPDIR not writable: " + tmp); Try / catch
try { fs = FileSystem.get(uri, conf); } catch (RuntimeException e) { if ("StubLoader load failed".equals(e.getMessage())) { LOG.error("native stub load failed", e.getCause()); /* fix OS/arch/libs per cause */ } throw e; } Prevention
- Check e.getCause() first — it names the real problem.
- Match the client build to OS/arch (musl vs glibc, amd64 vs arm64).
- Keep TMPDIR writable and clear stale extracted libraries after upgrades.
When it happens
Trigger: initStubLoader() fails to extract or System.load the bundled libjfs for the current OS/architecture; a previous load attempt left a non-null failure cause.
Common situations: Unsupported OS/architecture (no bundled binary, e.g. Alpine musl or ARM without a matching build); missing system dependencies for the .so; temp directory not writable so extraction fails; stale cached native lib in the temp dir.
Related errors
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/f2b86f031228af6d.
Report an issue: GitHub.