File tree Expand file tree Collapse file tree
build-logic/conventions/src/main/kotlin/com/datadoghq/profiler Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -399,20 +399,16 @@ class ProfilerTestPlugin : Plugin<Project> {
399399 }
400400
401401 // Environment variables
402- testConfig.environmentVariables.forEach { (key, value) ->
403- execTask.environment(key, value)
404- }
405-
406- // CRITICAL FIX: Remove LD_LIBRARY_PATH to let RPATH work correctly
402+ // CRITICAL FIX: Filter out LD_LIBRARY_PATH to let RPATH work correctly
407403 // The test JDK's launcher has RPATH set to find its own libraries ($ORIGIN/../lib/jli)
408404 // But LD_LIBRARY_PATH overrides RPATH and causes it to load the wrong libjli.so
409- // Solution: Unset LD_LIBRARY_PATH entirely to let RPATH take precedence
410- execTask.doFirst {
411- val currentLdLibPath = (execTask.environment[" LD_LIBRARY_PATH" ] as ? String ) ? : System .getenv(" LD_LIBRARY_PATH" )
412- if (! currentLdLibPath.isNullOrEmpty()) {
413- project.logger.info(" Removing LD_LIBRARY_PATH to prevent cross-JDK library conflicts (was: $currentLdLibPath )" )
414- execTask.environment.remove(" LD_LIBRARY_PATH" )
405+ // Solution: Never propagate LD_LIBRARY_PATH so RPATH takes precedence
406+ testConfig.environmentVariables.forEach { (key, value) ->
407+ if (key == " LD_LIBRARY_PATH" ) {
408+ project.logger.info(" Removing LD_LIBRARY_PATH to prevent cross-JDK library conflicts (was: $value )" )
409+ return @forEach
415410 }
411+ execTask.environment(key, value)
416412 }
417413
418414 // Sanitizer conditions
You can’t perform that action at this time.
0 commit comments