Skip to content

Commit 4b9e396

Browse files
committed
fix(builder): preserve existing LIBRARY_PATH when adding SDK path
Follow same pattern as LDFLAGS/CFLAGS handling - check for existing value and prepend rather than overwrite, preventing loss of paths that cargo/rustc might depend on.
1 parent 96b472e commit 4b9e396

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

internal/builder/library.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,19 @@ func buildEnv(installDir string) []string {
297297
}
298298

299299
// Also set LIBRARY_PATH for cargo/rustc which may not use LDFLAGS
300-
env = append(env, "LIBRARY_PATH="+filepath.Join(sdkPath, "usr", "lib"))
300+
libraryPath := filepath.Join(sdkPath, "usr", "lib")
301+
updatedLibraryPath := false
302+
for i, e := range env {
303+
if strings.HasPrefix(e, "LIBRARY_PATH=") {
304+
existing := strings.TrimPrefix(e, "LIBRARY_PATH=")
305+
env[i] = "LIBRARY_PATH=" + libraryPath + ":" + existing
306+
updatedLibraryPath = true
307+
break
308+
}
309+
}
310+
if !updatedLibraryPath {
311+
env = append(env, "LIBRARY_PATH="+libraryPath)
312+
}
301313
}
302314
}
303315
}

0 commit comments

Comments
 (0)