HMCL-dev/HMCL · error · IOException
Installed theme pack does not contain theme:
Error message
Installed theme pack does not contain theme:
What it means
The two-argument apply(ThemePack, Theme) convenience re-installs the pack file and then looks up the requested theme id in the freshly installed manifest. If findTheme(theme.id()) returns null, the installed pack does not contain that theme and this IOException is thrown with the theme id.
Solutions
- Obtain the Theme object from installedThemePack.manifest().findTheme(id) of the same pack you are applying, rather than reusing a stale Theme instance.
- Check themePack.manifest().findTheme(theme.id()) != null before calling apply.
- Update stored theme references after the pack file changes, since ids may be renamed between versions.
Example fix
// before
ThemePackManager.apply(packFile, staleTheme);
// after
InstalledThemePack installed = ThemePackManager.install(packFile);
Theme theme = installed.manifest().findTheme("my-theme");
if (theme != null) ThemePackManager.apply(installed, theme); Defensive patterns
Strategy: validation
Validate before calling
InstalledThemePack installed = ThemePackManager.install(pack.file());
Theme theme = installed.manifest().findTheme(themeId);
if (theme == null) throw new IllegalArgumentException("theme " + themeId + " not in pack");
ThemePackManager.apply(installed, theme); Try / catch
try {
ThemePackManager.apply(packFile, theme);
} catch (IOException e) {
if (e.getMessage().startsWith("Installed theme pack does not contain theme")) {
// refresh the Theme reference from the pack's current manifest
}
} Prevention
- Always resolve Theme objects from the same pack's manifest via findTheme(id)
- Invalidate cached Theme references whenever the pack file changes
- Check theme ids against the manifest after updating a pack
When it happens
Trigger: Calling apply(themePack, theme) with a Theme whose id does not exist in themePack's manifest — typically because the Theme object came from a different pack or an older/cached manifest than the file being installed.
Common situations: Applying a theme that was removed or renamed in an updated version of the pack; mixing Theme instances across packs; caching Theme references across an uninstall/reinstall of a different pack version.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Theme-pack asset entry is empty
- Theme-pack asset entry must be relative:
- Theme-pack asset entry must be under assets/:
- Theme-pack asset entry must be a file:
- Theme-pack asset entry contains an unsafe segment:
AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10).
Data as JSON: /api/errors/94aedba53c68e6b5.
Report an issue: GitHub.
Appendix: source
Thrown at HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackManager.java:582
if (replacementTheme == null) {
settings().selectedThemeProperty().set(BUILTIN_DEFAULT_THEME_REFERENCE);
}
}
}
/// Applies one theme from a loaded theme pack to current launcher settings.
///
/// @param themePack the loaded theme pack
/// @param theme the theme to apply
/// @throws IOException if the pack cannot be installed, referenced assets cannot be read, or settings cannot be applied
public static void apply(LoadedThemePack themePack, Theme theme) throws IOException {
Objects.requireNonNull(themePack);
Objects.requireNonNull(theme);
InstalledThemePack installedThemePack = install(themePack.file());
@Nullable Theme installedTheme = installedThemePack.manifest().findTheme(theme.id());
if (installedTheme == null) {
throw new IOException("Installed theme pack does not contain theme: " + theme.id());
}
apply(installedThemePack, installedTheme);
}
/// Applies one theme from an installed theme pack to current launcher settings.
///
/// @param themePack the installed theme pack
/// @param theme the theme to apply
/// @throws IOException if referenced assets cannot be read or settings cannot be applied
public static void apply(InstalledThemePack themePack, Theme theme) throws IOException {
Objects.requireNonNull(themePack);
Objects.requireNonNull(theme);
apply(themePack.manifest(), theme);
}
/// Applies one theme to current launcher settings.
///View on GitHub (pinned to 24702dc5a0)