{"record":{"id":"db46435c48a0e7db","repo":"HMCL-dev/HMCL","slug":"theme-pack-directory-does-not-contain","errorCode":null,"errorMessage":"Theme pack directory does not contain ","messagePattern":"Theme pack directory does not contain ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackManager.java","lineNumber":375,"sourceCode":"                    opacity);\n        }\n\n    }\n\n    /// Loads and parses a theme-pack file or unpacked theme-pack directory.\n    ///\n    /// @param file the theme-pack file or directory\n    /// @return the loaded theme pack\n    /// @throws IOException if the file cannot be read or the manifest is invalid\n    public static LoadedThemePack load(Path file) throws IOException {\n        Objects.requireNonNull(file);\n\n        Path normalizedFile = file.toAbsolutePath().normalize();\n        try {\n            if (Files.isDirectory(normalizedFile)) {\n                Path manifestFile = normalizedFile.resolve(ThemePackExporter.MANIFEST_ENTRY);\n                if (!Files.isRegularFile(manifestFile)) {\n                    throw new IOException(\"Theme pack directory does not contain \" + ThemePackExporter.MANIFEST_ENTRY);\n                }\n\n                ThemePackManifest manifest = JsonUtils.fromJsonFile(manifestFile, ThemePackManifest.class);\n                if (manifest == null) {\n                    throw new JsonParseException(\"Manifest is null\");\n                }\n                return new LoadedThemePack(normalizedFile, manifest);\n            }\n\n            try (var reader = new ZipArchiveReader(normalizedFile)) {\n                var manifestEntry = reader.getEntry(ThemePackExporter.MANIFEST_ENTRY);\n                if (manifestEntry == null || manifestEntry.isDirectory()) {\n                    throw new IOException(\"Theme pack does not contain \" + ThemePackExporter.MANIFEST_ENTRY);\n                }\n\n                ThemePackManifest manifest;\n                try (var inputStream = reader.getInputStream(manifestEntry)) {\n                    manifest = JsonUtils.fromNonNullJsonFully(inputStream, ThemePackManifest.class);","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackManager.java#L357-L393","documentation":"Thrown by ThemePackManager.load when the given path is a directory but does not contain the required manifest entry (theme.json as produced by ThemePackExporter). A directory-form theme pack is only valid if it includes the manifest file, so loading aborts with this IOException.","triggerScenarios":"Calling ThemePackManager.load on a directory path whose normalized location lacks ThemePackExporter.MANIFEST_ENTRY (theme.json) at its root.","commonSituations":"Pointing the loader at the wrong folder (parent dir or subfolder of the pack), unpacking an archive into a nested directory so the manifest sits one level deeper, or renaming/deleting theme.json during manual editing.","solutions":["Pass the directory that directly contains theme.json, not a parent or unrelated folder.","Restore or re-add the theme.json manifest to the directory root.","If loading an archive instead, pass the zip file itself rather than an extraction directory.","Check for nested packaging (pack-dir/pack-dir/theme.json) and load the inner directory."],"exampleFix":"// before\nmanager.load(Path.of(\"~/hmcl/themes/mytheme\"));      // dir missing theme.json\n// after\nmanager.load(Path.of(\"~/hmcl/themes/mytheme/pack\")); // dir containing theme.json","handlingStrategy":"validation","validationCode":"Path dir = file.toAbsolutePath().normalize();\nif (Files.isDirectory(dir) && !Files.isRegularFile(dir.resolve(\"theme.json\"))) {\n    throw new IllegalArgumentException(\"Directory has no theme.json: \" + dir);\n}","typeGuard":null,"tryCatchPattern":"try { manager.load(path); } catch (IOException e) { if (e.getMessage().startsWith(\"Theme pack directory does not contain\")) locateManifestAndRetry(); else throw e; }","preventionTips":["Load the directory that directly contains theme.json","Check for nested extraction folders before loading","Keep theme.json at the pack root when editing manually"],"tags":["io","theme-pack","file-not-found","manifest"],"backgroundTag":"file-not-found","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}