From 9cb6dc50b14428a6a76afaa4668ee586ca06fde7 Mon Sep 17 00:00:00 2001 From: Julian Vennen Date: Fri, 14 Jun 2024 12:03:21 +0200 Subject: [PATCH] Detect fabric mod dependency problems if the name is installed in the wrong version --- .../Fabric/FabricModDependencyProblem.php | 22 +- ...ric-1-20-1-dependencies-wrong-version.json | 358 ++++++++++++++++++ ...bric-1-20-1-dependencies-wrong-version.log | 22 ++ test/tests/Logs/AutoLogsTest.php | 10 + 4 files changed, 401 insertions(+), 11 deletions(-) create mode 100644 test/data/Vanilla/Fabric/fabric-1-20-1-dependencies-wrong-version.json create mode 100644 test/data/Vanilla/Fabric/fabric-1-20-1-dependencies-wrong-version.log diff --git a/src/Analysis/Problem/Fabric/FabricModDependencyProblem.php b/src/Analysis/Problem/Fabric/FabricModDependencyProblem.php index d80cee2..28f3bb6 100644 --- a/src/Analysis/Problem/Fabric/FabricModDependencyProblem.php +++ b/src/Analysis/Problem/Fabric/FabricModDependencyProblem.php @@ -37,12 +37,12 @@ public function getMessage(): string public static function getPatterns(): array { return [ - 'short-error' => '/net\.fabricmc\.loader\.discovery\.ModResolutionException: Could not find required mod: '. static::$modNamePattern .' requires {'. static::$modIDPattern .' @ \[([^\]]+)\]}/', - 'any' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version of (?:mod )?". static::$modIDPattern .",/", - 'minimum' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires version ([^ ]+) or later of (?:mod )?". static::$modIDPattern .",/", - 'any-after' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version after ([^ ]+) of (?:mod )?". static::$modIDPattern .",/", - 'any-before' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version before ([^ ]+) of (?:mod )?". static::$modIDPattern .",/", - 'specific' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires version ([^ ]+) of (?:mod )?". static::$modIDPattern .",/", + 'short-error' => '/net\.fabricmc\.loader\.discovery\.ModResolutionException: Could not find required mod: '. static::$modNamePattern .' requires {'. static::$modNamePattern .' @ \[([^\]]+)\]}/', + 'any' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version of (?:mod )?". static::$modNamePattern .",/", + 'minimum' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires version ([^ ]+) or later of (?:mod )?". static::$modNamePattern .",/", + 'any-after' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version after ([^ ]+) of (?:mod )?". static::$modNamePattern .",/", + 'any-before' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version before ([^ ]+) of (?:mod )?". static::$modNamePattern .",/", + 'specific' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires version ([^ ]+) of (?:mod )?". static::$modNamePattern .",/", 'between' => "/\s*- Mod ". static::$modNamePattern ."(?: [^ ]+)? requires any version between ([^ ]+) \((inclusive|exclusive)\) and ([^ ]+) \((inclusive|exclusive)\) of (?:mod )?". static::$modNamePattern .",/" ]; } @@ -59,17 +59,17 @@ public function setMatches(array $matches, mixed $patternKey): void switch ($patternKey) { case 'short-error': $this->setModName($matches[2]); - $this->setDependency($matches[3]); + $this->setDependency($matches[empty($matches[3]) ? 4 : 3]); $solution = (new ModInstallSolution())->setModName($this->getDependency()); - if ($matches[4] != '*') { - $solution->setModVersion($matches[4]); + if ($matches[5] != '*') { + $solution->setModVersion($matches[5]); } $this->addSolution($solution); return; case 'any': $this->setModName($matches[1]); - $this->setDependency($matches[3]); + $this->setDependency($matches[empty($matches[3]) ? 4 : 3]); $this->addSolution((new ModInstallSolution())->setModName($this->getDependency())); return; @@ -103,7 +103,7 @@ public function setMatches(array $matches, mixed $patternKey): void } $this->setModName($matches[1]); - $this->setDependency($matches[4]); + $this->setDependency($matches[empty($matches[4]) ? 5 : 4]); $this->addSolution((new ModInstallSolution())->setModName($this->getDependency())->setModVersion($symbol . $matches[3])); } diff --git a/test/data/Vanilla/Fabric/fabric-1-20-1-dependencies-wrong-version.json b/test/data/Vanilla/Fabric/fabric-1-20-1-dependencies-wrong-version.json new file mode 100644 index 0000000..c41d6e2 --- /dev/null +++ b/test/data/Vanilla/Fabric/fabric-1-20-1-dependencies-wrong-version.json @@ -0,0 +1,358 @@ +{ + "id": "fabric\/server", + "name": "Fabric", + "type": "Server Log", + "version": "1.20.1", + "title": "Fabric 1.20.1 Server Log", + "entries": [ + { + "level": 6, + "time": null, + "prefix": "[11:37:10] [main\/INFO]:", + "lines": [ + { + "number": 1, + "content": "[11:37:10] [main\/INFO]: Loading Minecraft 1.20.1 with Fabric Loader 0.14.23" + } + ] + }, + { + "level": 6, + "time": null, + "prefix": "[11:37:10] [main\/INFO]:", + "lines": [ + { + "number": 2, + "content": "[11:37:10] [main\/INFO]: Fabric is preparing JARs on first launch, this may take a few seconds..." + } + ] + }, + { + "level": 4, + "time": null, + "prefix": "[11:37:10] [main\/WARN]:", + "lines": [ + { + "number": 3, + "content": "[11:37:10] [main\/WARN]: Mod resolution failed" + } + ] + }, + { + "level": 6, + "time": null, + "prefix": "[11:37:10] [main\/INFO]:", + "lines": [ + { + "number": 4, + "content": "[11:37:10] [main\/INFO]: Immediate reason: [HARD_DEP_NO_CANDIDATE indium 1.0.27+mc1.20.1 {depends sodium @ [0.5.3]}, ROOT_FORCELOAD_SINGLE indium 1.0.27+mc1.20.1]" + } + ] + }, + { + "level": 6, + "time": null, + "prefix": "[11:37:10] [main\/INFO]:", + "lines": [ + { + "number": 5, + "content": "[11:37:10] [main\/INFO]: Reason: [HARD_DEP indium 1.0.27+mc1.20.1 {depends sodium @ [0.5.3]}, HARD_DEP indium 1.0.27+mc1.20.1 {depends fabric-renderer-api-v1 @ [>=3.2.0]}]" + } + ] + }, + { + "level": 6, + "time": null, + "prefix": "[11:37:10] [main\/INFO]:", + "lines": [ + { + "number": 6, + "content": "[11:37:10] [main\/INFO]: Fix: add [], remove [], replace [[indium 1.0.27+mc1.20.1] -> add:indium 1 ([(-\u221e,\u221e)])]" + } + ] + }, + { + "level": 3, + "time": null, + "prefix": "[11:37:10] [main\/ERROR]:", + "lines": [ + { + "number": 7, + "content": "[11:37:10] [main\/ERROR]: Incompatible mods found!" + }, + { + "number": 8, + "content": "net.fabricmc.loader.impl.FormattedException: Some of your mods are incompatible with the game or each other!" + }, + { + "number": 9, + "content": "A potential solution has been determined, this may resolve your problem:" + }, + { + "number": 10, + "content": "\t - Replace mod 'Indium' (indium) 1.0.27+mc1.20.1 with any version that is compatible with:" + }, + { + "number": 11, + "content": "\t\t - sodium 0.4.10+build.27" + }, + { + "number": 12, + "content": "More details:" + }, + { + "number": 13, + "content": "\t - Mod 'Indium' (indium) 1.0.27+mc1.20.1 requires version 0.5.3 of mod 'Sodium' (sodium), but only the wrong version is present: 0.4.10+build.27!" + }, + { + "number": 14, + "content": "\t - Mod 'Indium' (indium) 1.0.27+mc1.20.1 requires version 3.2.0 or later of fabric-renderer-api-v1, which is missing!" + }, + { + "number": 15, + "content": "\tat net.fabricmc.loader.impl.FormattedException.ofLocalized(FormattedException.java:51) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 16, + "content": "\tat net.fabricmc.loader.impl.FabricLoaderImpl.load(FabricLoaderImpl.java:194) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 17, + "content": "\tat net.fabricmc.loader.impl.launch.knot.Knot.init(Knot.java:146) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 18, + "content": "\tat net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:68) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 19, + "content": "\tat net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 20, + "content": "\tat org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:100) ~[?:?]" + }, + { + "number": 21, + "content": "\tat org.prismlauncher.EntryPoint.listen(EntryPoint.java:129) ~[?:?]" + }, + { + "number": 22, + "content": "\tat org.prismlauncher.EntryPoint.main(EntryPoint.java:70) ~[?:?]" + }, + { + "number": 23, + "content": "" + } + ] + } + ], + "analysis": { + "problems": [ + { + "message": "The mod 'Indium' is missing the required mod 'fabric-renderer-api-v1'.", + "counter": 1, + "entry": { + "level": 3, + "time": null, + "prefix": "[11:37:10] [main\/ERROR]:", + "lines": [ + { + "number": 7, + "content": "[11:37:10] [main\/ERROR]: Incompatible mods found!" + }, + { + "number": 8, + "content": "net.fabricmc.loader.impl.FormattedException: Some of your mods are incompatible with the game or each other!" + }, + { + "number": 9, + "content": "A potential solution has been determined, this may resolve your problem:" + }, + { + "number": 10, + "content": "\t - Replace mod 'Indium' (indium) 1.0.27+mc1.20.1 with any version that is compatible with:" + }, + { + "number": 11, + "content": "\t\t - sodium 0.4.10+build.27" + }, + { + "number": 12, + "content": "More details:" + }, + { + "number": 13, + "content": "\t - Mod 'Indium' (indium) 1.0.27+mc1.20.1 requires version 0.5.3 of mod 'Sodium' (sodium), but only the wrong version is present: 0.4.10+build.27!" + }, + { + "number": 14, + "content": "\t - Mod 'Indium' (indium) 1.0.27+mc1.20.1 requires version 3.2.0 or later of fabric-renderer-api-v1, which is missing!" + }, + { + "number": 15, + "content": "\tat net.fabricmc.loader.impl.FormattedException.ofLocalized(FormattedException.java:51) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 16, + "content": "\tat net.fabricmc.loader.impl.FabricLoaderImpl.load(FabricLoaderImpl.java:194) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 17, + "content": "\tat net.fabricmc.loader.impl.launch.knot.Knot.init(Knot.java:146) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 18, + "content": "\tat net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:68) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 19, + "content": "\tat net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 20, + "content": "\tat org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:100) ~[?:?]" + }, + { + "number": 21, + "content": "\tat org.prismlauncher.EntryPoint.listen(EntryPoint.java:129) ~[?:?]" + }, + { + "number": 22, + "content": "\tat org.prismlauncher.EntryPoint.main(EntryPoint.java:70) ~[?:?]" + }, + { + "number": 23, + "content": "" + } + ] + }, + "solutions": [ + { + "message": "Install the mod 'fabric-renderer-api-v1' with version >=3.2.0." + } + ] + }, + { + "message": "The mod 'Indium' is missing the required mod 'Sodium'.", + "counter": 1, + "entry": { + "level": 3, + "time": null, + "prefix": "[11:37:10] [main\/ERROR]:", + "lines": [ + { + "number": 7, + "content": "[11:37:10] [main\/ERROR]: Incompatible mods found!" + }, + { + "number": 8, + "content": "net.fabricmc.loader.impl.FormattedException: Some of your mods are incompatible with the game or each other!" + }, + { + "number": 9, + "content": "A potential solution has been determined, this may resolve your problem:" + }, + { + "number": 10, + "content": "\t - Replace mod 'Indium' (indium) 1.0.27+mc1.20.1 with any version that is compatible with:" + }, + { + "number": 11, + "content": "\t\t - sodium 0.4.10+build.27" + }, + { + "number": 12, + "content": "More details:" + }, + { + "number": 13, + "content": "\t - Mod 'Indium' (indium) 1.0.27+mc1.20.1 requires version 0.5.3 of mod 'Sodium' (sodium), but only the wrong version is present: 0.4.10+build.27!" + }, + { + "number": 14, + "content": "\t - Mod 'Indium' (indium) 1.0.27+mc1.20.1 requires version 3.2.0 or later of fabric-renderer-api-v1, which is missing!" + }, + { + "number": 15, + "content": "\tat net.fabricmc.loader.impl.FormattedException.ofLocalized(FormattedException.java:51) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 16, + "content": "\tat net.fabricmc.loader.impl.FabricLoaderImpl.load(FabricLoaderImpl.java:194) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 17, + "content": "\tat net.fabricmc.loader.impl.launch.knot.Knot.init(Knot.java:146) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 18, + "content": "\tat net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:68) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 19, + "content": "\tat net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) ~[fabric-loader-0.14.23.jar:?]" + }, + { + "number": 20, + "content": "\tat org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:100) ~[?:?]" + }, + { + "number": 21, + "content": "\tat org.prismlauncher.EntryPoint.listen(EntryPoint.java:129) ~[?:?]" + }, + { + "number": 22, + "content": "\tat org.prismlauncher.EntryPoint.main(EntryPoint.java:70) ~[?:?]" + }, + { + "number": 23, + "content": "" + } + ] + }, + "solutions": [ + { + "message": "Install the mod 'Sodium' with version 0.5.3." + } + ] + } + ], + "information": [ + { + "message": "Minecraft version: 1.20.1", + "counter": 1, + "entry": { + "level": 6, + "time": null, + "prefix": "[11:37:10] [main\/INFO]:", + "lines": [ + { + "number": 1, + "content": "[11:37:10] [main\/INFO]: Loading Minecraft 1.20.1 with Fabric Loader 0.14.23" + } + ] + }, + "label": "Minecraft version", + "value": "1.20.1" + }, + { + "message": "Fabric loader version: 0.14.23", + "counter": 1, + "entry": { + "level": 6, + "time": null, + "prefix": "[11:37:10] [main\/INFO]:", + "lines": [ + { + "number": 1, + "content": "[11:37:10] [main\/INFO]: Loading Minecraft 1.20.1 with Fabric Loader 0.14.23" + } + ] + }, + "label": "Fabric loader version", + "value": "0.14.23" + } + ] + } +} \ No newline at end of file diff --git a/test/data/Vanilla/Fabric/fabric-1-20-1-dependencies-wrong-version.log b/test/data/Vanilla/Fabric/fabric-1-20-1-dependencies-wrong-version.log new file mode 100644 index 0000000..d738611 --- /dev/null +++ b/test/data/Vanilla/Fabric/fabric-1-20-1-dependencies-wrong-version.log @@ -0,0 +1,22 @@ +[11:37:10] [main/INFO]: Loading Minecraft 1.20.1 with Fabric Loader 0.14.23 +[11:37:10] [main/INFO]: Fabric is preparing JARs on first launch, this may take a few seconds... +[11:37:10] [main/WARN]: Mod resolution failed +[11:37:10] [main/INFO]: Immediate reason: [HARD_DEP_NO_CANDIDATE indium 1.0.27+mc1.20.1 {depends sodium @ [0.5.3]}, ROOT_FORCELOAD_SINGLE indium 1.0.27+mc1.20.1] +[11:37:10] [main/INFO]: Reason: [HARD_DEP indium 1.0.27+mc1.20.1 {depends sodium @ [0.5.3]}, HARD_DEP indium 1.0.27+mc1.20.1 {depends fabric-renderer-api-v1 @ [>=3.2.0]}] +[11:37:10] [main/INFO]: Fix: add [], remove [], replace [[indium 1.0.27+mc1.20.1] -> add:indium 1 ([(-∞,∞)])] +[11:37:10] [main/ERROR]: Incompatible mods found! +net.fabricmc.loader.impl.FormattedException: Some of your mods are incompatible with the game or each other! +A potential solution has been determined, this may resolve your problem: + - Replace mod 'Indium' (indium) 1.0.27+mc1.20.1 with any version that is compatible with: + - sodium 0.4.10+build.27 +More details: + - Mod 'Indium' (indium) 1.0.27+mc1.20.1 requires version 0.5.3 of mod 'Sodium' (sodium), but only the wrong version is present: 0.4.10+build.27! + - Mod 'Indium' (indium) 1.0.27+mc1.20.1 requires version 3.2.0 or later of fabric-renderer-api-v1, which is missing! + at net.fabricmc.loader.impl.FormattedException.ofLocalized(FormattedException.java:51) ~[fabric-loader-0.14.23.jar:?] + at net.fabricmc.loader.impl.FabricLoaderImpl.load(FabricLoaderImpl.java:194) ~[fabric-loader-0.14.23.jar:?] + at net.fabricmc.loader.impl.launch.knot.Knot.init(Knot.java:146) ~[fabric-loader-0.14.23.jar:?] + at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:68) ~[fabric-loader-0.14.23.jar:?] + at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) ~[fabric-loader-0.14.23.jar:?] + at org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:100) ~[?:?] + at org.prismlauncher.EntryPoint.listen(EntryPoint.java:129) ~[?:?] + at org.prismlauncher.EntryPoint.main(EntryPoint.java:70) ~[?:?] diff --git a/test/tests/Logs/AutoLogsTest.php b/test/tests/Logs/AutoLogsTest.php index 74f1083..9557807 100644 --- a/test/tests/Logs/AutoLogsTest.php +++ b/test/tests/Logs/AutoLogsTest.php @@ -554,6 +554,16 @@ public function test_fabric_1_19_crash_report(): void $this->assertStringEqualsFile($log->getExpectedPath(), $log->getOutput(), $log->getLogPath()); } + /** + * @return void + * @throws Exception + */ + public function test_fabric_1_20_1_dependencies_wrong_version(): void + { + $log = new TestLog('Vanilla/Fabric/fabric-1-20-1-dependencies-wrong-version.log'); + $this->assertStringEqualsFile($log->getExpectedPath(), $log->getOutput(), $log->getLogPath()); + } + /** * @return void * @throws Exception