fixed: forge/neoforge libraries from instance .minecraft/libraries not on classpath

modern forge's installer places some libraries (notably the bootstrap
library that defines ForgeBootstrap / BootstrapLauncher) into the
instance's .minecraft/libraries/ rather than the shared meta cache. the
unified classpath loop introduced in the rework checked downloads.artifact
first and pushed meta_dir/libraries/<path> without ever consulting the
local installer dir for libraries that had downloads.artifact set.

resolve a single relative path per library (downloads.artifact.path if
present, else maven_coord_to_path(name)), then for has_local_libs check
the local installer dir first regardless of which path source we used.
fixes ClassNotFoundException at launch on forge 1.20.6 and likely
similar versions.
This commit is contained in:
objz committed 2026-05-25 20:58:05 +02:00
1 parent 363ada8211
commit d88ab085b5
1 file changed
+31 -13
+31 -13
View File
@@ -310,21 +310,32 @@ pub async fn launch(
continue; continue;
} }
if let Some(artifact) = lib.downloads.as_ref().and_then(|d| d.artifact.as_ref()) { // resolve a relative path for this library. prefer downloads.artifact.path
classpath.push(lib_dir.join(&artifact.path)); // when present (vanilla-style), fall back to maven_coord_to_path(name)
} else if let Some(rel) = crate::net::maven_coord_to_path(&lib.name) { // for loader-style entries that only have a coord.
if has_local_libs { let rel: PathBuf = match lib
let in_local = local_lib_dir.join(&rel); .downloads
let in_meta = lib_dir.join(&rel); .as_ref()
if in_local.exists() { .and_then(|d| d.artifact.as_ref())
classpath.push(in_local); .map(|a| PathBuf::from(&a.path))
} else if in_meta.exists() { .or_else(|| crate::net::maven_coord_to_path(&lib.name).map(PathBuf::from))
classpath.push(in_meta); {
} Some(p) => p,
} else { None => continue,
classpath.push(lib_dir.join(rel)); };
// for forge/neoforge, the installer drops some libs (notably the
// bootstrap library) into <instance>/.minecraft/libraries/ rather
// than the shared meta cache. check there first regardless of
// whether the lib has a downloads.artifact entry.
if has_local_libs {
let in_local = local_lib_dir.join(&rel);
if in_local.exists() {
classpath.push(in_local);
continue;
} }
} }
classpath.push(lib_dir.join(rel));
} }
classpath.push( classpath.push(
@@ -425,10 +436,12 @@ pub async fn launch(
.join("versions") .join("versions")
.join(&config.game_version) .join(&config.game_version)
.join("natives"); .join("natives");
let version_type = merged_profile.type_.as_deref().unwrap_or("release");
let template_ctx = TemplateContext { let template_ctx = TemplateContext {
library_directory: &lib_dir, library_directory: &lib_dir,
classpath_separator: sep, classpath_separator: sep,
version_name: &config.game_version, version_name: &config.game_version,
version_type,
natives_directory: &natives_dir, natives_directory: &natives_dir,
classpath: &cp_str, classpath: &cp_str,
game_directory: &minecraft_dir, game_directory: &minecraft_dir,
@@ -443,6 +456,8 @@ pub async fn launch(
launcher_name: "rmcl", launcher_name: "rmcl",
launcher_version: env!("CARGO_PKG_VERSION"), launcher_version: env!("CARGO_PKG_VERSION"),
clientid: "0", clientid: "0",
resolution_width: "",
resolution_height: "",
}; };
let (upstream_jvm_args, game_args) = let (upstream_jvm_args, game_args) =
@@ -620,6 +635,9 @@ mod tests {
launcher_name: "rmcl", launcher_name: "rmcl",
launcher_version: "test", launcher_version: "test",
clientid: "0", clientid: "0",
version_type: "release",
resolution_width: "",
resolution_height: "",
}; };
let features = FeatureSet::default(); let features = FeatureSet::default();
let rule_ctx = RuleContext { let rule_ctx = RuleContext {