sfackler / rust-openssl

OpenSSL bindings for Rust
1.39k stars 742 forks source link

openssl-sys | mac | Doesn't respect `brew --prefix` #1813

Open skull-squadron opened 1 year ago

skull-squadron commented 1 year ago

Expected

It should just work.

Encountered

Tries to link to unrelated brew environment with a different architecture and fails to compile. Several utility crates are affected.

Use case

There is an installation at /opt/homebrew/ for a different architecture that absolutely cannot be moved. Cannot do magic environment variables workarounds because this is fragile and not scalable.

Solution

Trying random "well-known" locations particular to tools is fragile, breaks repeatability, separations of concerns, and isolation of builds and dev environments.

Instead of guessing at locations, if the brew command exists, ask it for the source of truth brew --prefix openssl@{{n}}.

sfackler commented 1 year ago

The current logic is pretty explicit about why this is done:

        // Calling `brew --prefix <package>` command is usually slow and
        // takes seconds, and will be used only as a last resort.
skull-squadron commented 1 year ago

Premature optimization is the root of all evil, especially when it doesn't work.

HOMEBREW_NO_AUTO_UPDATE=1 brew shellenv | sed '/HOMEBREW_PREFIX/!d;s/[^"]*"//;s!".*!/opt!' is guaranteed to be instantaneous.

skull-squadron commented 1 year ago

Homebrew = root $ root $ evil -- sigh

sfackler commented 1 year ago

Please describe to me how this optimization was made prematurely.