[Bug]: ld failed to find Security framework on macOS

This issue has been tracked since 2023-01-25.


I'm trying to use a rust library that supports TLS (https), but when I'm trying to run my application it results in a linker error.

Here are some details and a reproducible sandbox environment.
My devbox.json contains:

  "packages": [
  "shell": {
    "init_hook": null
  "nixpkgs": {
    "commit": "52e3e80afff4b16ccb7c52e9f0f5220552f03d04"

I created a minimal rust project.
My Cargo.toml contains:

name = "dbox"
version = "0.1.0"
edition = "2021"

version = "0.11"
features = ["blocking"] # Also I tried with "native-tls-vendored", but no luck

and my main.rs is also very simple

fn main() {
    let resp = reqwest::blocking::get("https://www.apple.com")
        .expect("Cannot get the response");

So when I tried to run with cargo run I got the following error:

error: linking with `cc` failed: exit status: 1
= note: "cc" "-arch" "arm64" "/tmp/rustcQyCR0l/symbols.o" < not_relevan_section > "-framework" "Security" "-framework" "CoreFoundation" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/nix/store/y1zgd02zpwwd71i41riyyq7rs6l20sqs-rustc-1.64.0/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/pinter/Projects/dbox/target/debug/deps/dbox-3d532d05e5ae30ee" "-Wl,-dead_strip" "-nodefaultlibs"
= note: ld: framework not found Security
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

I'm running this on a M1 Apple Mac mini
OS version: 13.1 (22C65)
rustc 1.66.1 (90743e729 2023-01-10)
devbox version 0.2.2

Thanks for this awesome tool and for the help as well!

Lagoja wrote this answer on 2023-01-27

Hey Andras, we'll take a deeper look into what's going on in the error message above. For now, it looks like you need to explicitly add the Security framework in MacOS. Try editing your packages to the following:

    "packages": [

Once I added the framework, i was able to successfully run cargo run

andras-pinter wrote this answer on 2023-01-27

Hi @Lagoja ,

Thank you! I'm kinda new in the nix world and I did not know that I could add packages and frameworks like that.

Your workaround suggestion works smoothly! On the other hand in this case I'm losing the portability of my devbox environment since the "MacOS_SDK-10.12" package won't be available on Linux platforms.

And as I checked out that's the exact case 😞

Installing nix packages. This may take a while...
Error: apply Nix derivation: running command /home/pinter/.nix-profile/bin/nix-env --profile /home/pinter/Projects/dbox/.devbox/nix/profile/default --install -f /home/pinter/Projects/dbox/.devbox/gen/development.nix: exit status 1 with command stderr: installing 'devbox-development'
error: Package ‘MacOS_SDK-10.12’ in /nix/store/j5a7i3dvxslg2ychfy53wdhg1m3xfrwm-source/pkgs/os-specific/darwin/apple-sdk/default.nix:50 is not supported on ‘x86_64-linux’, refusing to evaluate.

However, I did not try setting the NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM environment variable.

But many thanks for looking into this! Thumbs up to you guys!

More Details About Repo
Owner Name jetpack-io
Repo Name devbox
Full Name jetpack-io/devbox
Language Go
Created Date 2022-08-18
Updated Date 2023-03-31
Star Count 4960
Watcher Count 19
Fork Count 68
Issue Count 42


Issue Title Created Date Updated Date