Skip to content

Commit f8a6297

Browse files
committed
Fix macOS: clear Homebrew library paths in maturin builds to prevent @rpath errors
1 parent fecbc4d commit f8a6297

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

crates/pecos/src/bin/cli/python_cmd.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ fn run_build(profile: &str, rustflags: Option<&str>, cuda: bool) -> Result<()> {
130130
}
131131
cmd.env("PATH", &path_with_venv);
132132
cmd.env_remove("CONDA_PREFIX");
133+
// On macOS, prevent Homebrew library paths from polluting the linker
134+
// (causes @rpath/libc++.1.dylib errors in the built .so)
135+
#[cfg(target_os = "macos")]
136+
{
137+
cmd.env_remove("LIBRARY_PATH");
138+
cmd.env_remove("LD_LIBRARY_PATH");
139+
cmd.env_remove("DYLD_LIBRARY_PATH");
140+
cmd.env_remove("DYLD_FALLBACK_LIBRARY_PATH");
141+
cmd.env("LIBRARY_PATH", "/usr/lib");
142+
}
133143

134144
let status = cmd.status();
135145
match status {

0 commit comments

Comments
 (0)