@@ -25,14 +25,52 @@ export function resetInstalledTracker(): void {
25
25
globalCompletedPackages . clear ( )
26
26
}
27
27
28
+ /**
29
+ * Resolve critical system library conflicts (like OpenSSL) to prevent runtime issues
30
+ */
31
+ function resolveCriticalLibraryConflicts ( packages : string [ ] ) : string [ ] {
32
+ const packageMap = new Map < string , string > ( )
33
+ const criticalLibraries = new Set ( [ 'openssl.org' , 'libssl' , 'libcrypto' ] )
34
+
35
+ // First pass: collect all packages
36
+ for ( const pkg of packages ) {
37
+ const { name } = parsePackageSpec ( pkg )
38
+ const domain = resolvePackageName ( name )
39
+ packageMap . set ( domain , pkg )
40
+ }
41
+
42
+ // Second pass: resolve critical library conflicts
43
+ for ( const domain of criticalLibraries ) {
44
+ if ( packageMap . has ( domain ) ) {
45
+ const pkg = packageMap . get ( domain ) !
46
+ const { version } = parsePackageSpec ( pkg )
47
+
48
+ // Force OpenSSL to use 1.1.1w for maximum compatibility
49
+ if ( domain === 'openssl.org' ) {
50
+ // Always prefer OpenSSL 1.1.1w for compatibility with most software
51
+ const compatiblePkg = `[email protected] `
52
+ packageMap . set ( domain , compatiblePkg )
53
+ if ( config . verbose ) {
54
+ console . warn ( `🔒 Resolved OpenSSL conflict: ${ pkg } -> ${ compatiblePkg } for maximum compatibility` )
55
+ }
56
+ }
57
+ }
58
+ }
59
+
60
+ return Array . from ( packageMap . values ( ) )
61
+ }
62
+
28
63
// Use ts-pkgx API to resolve all dependencies with proper version conflict resolution
29
64
export async function resolveAllDependencies ( packages : string [ ] ) : Promise < string [ ] > {
65
+ // First resolve critical library conflicts
66
+ const conflictResolvedPackages = resolveCriticalLibraryConflicts ( packages )
67
+
30
68
try {
31
69
// Import resolveDependencies from ts-pkgx
32
70
const { resolveDependencies } = await import ( 'ts-pkgx' )
33
71
34
- // Create a temporary dependency file content
35
- const depsYaml = packages . reduce ( ( acc , pkg ) => {
72
+ // Create a temporary dependency file content using conflict-resolved packages
73
+ const depsYaml = conflictResolvedPackages . reduce ( ( acc , pkg ) => {
36
74
const { name, version } = parsePackageSpec ( pkg )
37
75
acc [ name ] = version || '*'
38
76
return acc
@@ -84,7 +122,7 @@ export async function resolveAllDependencies(packages: string[]): Promise<string
84
122
console . warn ( `Failed to use ts-pkgx for dependency resolution: ${ error instanceof Error ? error . message : String ( error ) } ` )
85
123
console . warn ( 'Falling back to simple deduplication...' )
86
124
}
87
- return deduplicatePackagesByVersion ( packages )
125
+ return deduplicatePackagesByVersion ( conflictResolvedPackages )
88
126
}
89
127
}
90
128
@@ -2603,8 +2641,14 @@ async function installDependencies(
2603
2641
// Strategy 3: Check for well-known version compatibility mappings
2604
2642
const versionCompatibilityMap : Record < string , Record < string , string [ ] > > = {
2605
2643
'openssl.org' : {
2606
- '^1.1' : [ '3.5.0' , '3.4.0' , '3.3.2' ] , // OpenSSL 3.x is backward compatible with 1.x APIs
2607
- '^1.0' : [ '3.5.0' , '3.4.0' , '3.3.2' ] ,
2644
+ // CORRECTED: OpenSSL 3.x is NOT backward compatible with 1.x due to ABI changes
2645
+ // Instead, prefer 1.x versions for broader compatibility
2646
+ '^3.0' : [ '1.1.1w' , '1.1.1u' , '1.1.1t' ] , // Prefer stable 1.1.1 for compatibility
2647
+ '^3.1' : [ '1.1.1w' , '1.1.1u' , '1.1.1t' ] ,
2648
+ '^3.2' : [ '1.1.1w' , '1.1.1u' , '1.1.1t' ] ,
2649
+ '^3.3' : [ '1.1.1w' , '1.1.1u' , '1.1.1t' ] ,
2650
+ '^3.4' : [ '1.1.1w' , '1.1.1u' , '1.1.1t' ] ,
2651
+ '^3.5' : [ '1.1.1w' , '1.1.1u' , '1.1.1t' ] ,
2608
2652
} ,
2609
2653
'zlib.net' : {
2610
2654
'^1.2' : [ '1.3.1' , '1.3.0' ] , // zlib 1.3.x is compatible with 1.2.x
@@ -2967,7 +3011,11 @@ export async function install(packages: PackageSpec | PackageSpec[], basePath?:
2967
3011
}
2968
3012
2969
3013
// Use ts-pkgx to resolve all dependencies with proper version conflict resolution
2970
- const resolvedPackages = await resolveAllDependencies ( packageList )
3014
+ let resolvedPackages = await resolveAllDependencies ( packageList )
3015
+
3016
+ // Apply critical library conflict resolution again in case global packages interfere
3017
+ resolvedPackages = resolveCriticalLibraryConflicts ( resolvedPackages )
3018
+
2971
3019
const deduplicatedPackages = resolvedPackages
2972
3020
2973
3021
// Skip recursive dependency resolution since ts-pkgx already resolved everything
0 commit comments