Skip to content

Commit 2c6b0c6

Browse files
authored
fix: if no native library is available for this arch, don't include in classpath (#8139)
* fix: if no native library is available for this arch, don't include in classpath * fmt
1 parent 2bb257a commit 2c6b0c6

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

‎packages/app-lib/src/launcher/args.rs‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,11 @@ pub fn get_class_paths(
5555
return None;
5656
}
5757

58-
if !library.include_in_classpath {
58+
if !library.include_in_classpath || library.is_native() {
5959
return None;
6060
}
6161

62-
Some(get_lib_path(
63-
libraries_path,
64-
&library.name,
65-
library.native_classifier(java_arch).is_some(),
66-
))
62+
Some(get_lib_path(libraries_path, &library.name, false))
6763
}))
6864
.process_results(|iter| {
6965
iter.unique().join(classpath_separator(java_arch))

‎packages/app-lib/src/launcher/download.rs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,16 @@ pub async fn download_libraries(
890890
return Ok(());
891891
}
892892

893-
// When a library has natives, we only need to download such natives, as PrismLauncher does
893+
if library.is_native()
894+
&& library.native_classifier(java_arch).is_none()
895+
{
896+
tracing::trace!(
897+
"Skipped incompatible native library {}",
898+
&library.name
899+
);
900+
return Ok(());
901+
}
902+
894903
if let Some((url, sha1, size)) =
895904
library.native_download(java_arch)?
896905
{

‎packages/app-lib/src/launcher/library.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use minecraft_meta_manifest::{
66
use url::Url;
77

88
pub(crate) trait LibraryExt {
9+
/// Whether this library declares platform-specific native classifiers.
10+
fn is_native(&self) -> bool;
11+
912
/// Native classification does not depend on classifier download metadata.
1013
fn native_classifier(&self, java_arch: &str) -> Option<String>;
1114

@@ -17,6 +20,12 @@ pub(crate) trait LibraryExt {
1720
}
1821

1922
impl LibraryExt for Library {
23+
fn is_native(&self) -> bool {
24+
self.natives
25+
.as_ref()
26+
.is_some_and(|natives| !natives.is_empty())
27+
}
28+
2029
/// Native classification does not depend on classifier download metadata.
2130
fn native_classifier(&self, java_arch: &str) -> Option<String> {
2231
let natives = self.natives.as_ref()?;

0 commit comments

Comments
 (0)