libgdx/libgdx · error · GdxRuntimeException
Cannot get the sibling of the root.
Error message
Cannot get the sibling of the root.
What it means
IOSFileHandle.sibling(name) refuses to build a sibling path when the current file's path is empty (length 0), i.e. the handle represents the root itself — a root has no parent directory, so a sibling is undefined. The Android/desktop backends share this semantics; only the message is iOS-specific.
Source
Thrown at backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSFileHandle.java:41
if (file.getPath().length() == 0) return new IOSFileHandle(new File(name), type);
return new IOSFileHandle(new File(file, name), type);
}
@Override
public FileHandle parent () {
File parent = file.getParentFile();
if (parent == null) {
if (type == FileType.Absolute)
parent = new File("/");
else
parent = new File("");
}
return new IOSFileHandle(parent, type);
}
@Override
public FileHandle sibling (String name) {
if (file.getPath().length() == 0) throw new GdxRuntimeException("Cannot get the sibling of the root.");
return new IOSFileHandle(new File(file.getParent(), name), type);
}
@Override
public File file () {
if (type == FileType.Internal) return new File(IOSFiles.internalPath, file.getPath());
if (type == FileType.External) return new File(IOSFiles.externalPath, file.getPath());
if (type == FileType.Local) return new File(IOSFiles.localPath, file.getPath());
return file;
}
}
View on GitHub (pinned to 97f4086187)
Solutions
- Guard the call: skip or special-case when the handle path is empty.
- Fix upstream logic so sibling() is only invoked on non-root handles (check file.getPath().length() > 0 first).
- If you intended a child of root, use child(name) instead of sibling(name).
Example fix
// before
FileHandle next = dir.sibling("save.dat"); // throws if dir is root
// after
FileHandle next = dir.file.getPath().length() == 0 ? dir.child("save.dat") : dir.sibling("save.dat"); Defensive patterns
Strategy: type-guard
Validate before calling
if (dir.file.getPath().length() == 0) { /* at root: no sibling exists */ } Type guard
static boolean hasSibling(FileHandle h) { return h.file.getPath().length() > 0; } Prevention
- Use child() when you mean 'under root'.
- Bound parent()-walking loops before reaching the empty root path.
When it happens
Trigger: Calling sibling(...) on a FileHandle constructed from an empty path string, e.g. new IOSFileHandle("", type).sibling("x"), or code that walks up to root via parent() and then calls sibling().
Common situations: Path-manipulation utilities that call parent() repeatedly then sibling() at the top; constructing handles from user input where the empty string slips through; relative-path handling that normalizes to empty.
Related errors
- Cannot get the sibling of the root.
- Can't open KeyBoard, if TextInputField KeyBoard is already o
- Can't open TextInputField, if KeyBoard is already open
- Couldn't find free pointer id!
- iOS audio is not enabled by the application config
AI-assisted analysis of libgdx/libgdx@97f4086187 (2026-08-14).
Data as JSON: /api/errors/4d6538f2b87d55eb.
Report an issue: GitHub.