Hey! I’m very new to nix and I’m trying to understand how it works.
I’m using the nix-env command as a package manager on macOS Ventura (intel cpu), because I don’t really like homebrew.
I’m trying to install cargo-outdated via cargo install --locked cargo-outdated, which requires that openssl dev is available.
So I did the following:
$ nix-env -iA nixpkgs.openssl.dev # (I also tried nixpkgs.openssl)
$ nix-env -iA nixpkgs.pkg-config
However, the install fails with:
run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit status: 1\nerror: could not find system library 'openssl' required by the 'openssl-sys' crate\n\n--- stderr\nPackage openssl was not found in the pkg-config search path.\nPerhaps you should add the directory containing `openssl.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'openssl' found\n"
This is the same error I get if I run: pkg-config --libs --cflags openssl. But pkg-config is installed correctly:
$ which pkg-config
/Users/beeb/.nix-profile/bin/pkg-config
And when I do echo $PKG_CONFIG_PATH, the environment variable is empty.
How can I have pkg-config report the correct path for openssl so that cargo can build the openssl-sys crate?
Thanks for the reply! I prefer to have my cargo tools installed with cargo (same ecosystem) and sometimes the latest version is not available in the nix repo. Also, this problem happens with all my dependencies that require openssl, even when they are not in nixpkgs.
When doing nix-shell -p openssl pkg-config followed by cargo install ... I get a long list of errors, all of them look like this:
error: could not compile `libz-sys` due to previous error
error: could not compile `curl-sys` due to previous error
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-arch" "x86_64" "-m64" "/tmp/rustcRIRoo1/symbols.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.0.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.1.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.10.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.11.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.12.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.13.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.14.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.15.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.2.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.3.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.4.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.5.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.6.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.7.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.8.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.build_script_build.1b20f158-cgu.9.rcgu.o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43.q3teg2hp3s1zgzb.rcgu.o" "-L" "/tmp/cargo-installPZzKPk/release/deps" "-L" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/private/tmp/cargo-installPZzKPk/release/deps/libcc-a9973e370efb114d.rlib" "/private/tmp/cargo-installPZzKPk/release/deps/libjobserver-aa4dbf599d79960b.rlib" "/private/tmp/cargo-installPZzKPk/release/deps/liblibc-801fdcbdcf1d73a9.rlib" "/private/tmp/cargo-installPZzKPk/release/deps/libpkg_config-ef4474434ab73c8d.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-8ccc66d291e26c47.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-a73124e4adaa92c6.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-3eb2f4ed88da0006.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libmemchr-cf14fc8ae0761079.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-75fc3691d2ef2683.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-f1944668c71a48ef.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-af619ab1a4f1eee8.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_detect-c95dc73b81b88b12.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-8ca83a77c964155f.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libminiz_oxide-8e689db31063e515.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libadler-0f024e3bc2785d8d.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-bdca385064453076.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-47ff4c352f579ade.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-30e5d96622454c9c.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-7931f38b6f145964.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-c36efbe8b4e63374.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-3a0946359a415a32.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-422e5db879f57430.rlib" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-f10c7b859b5fa696.rlib" "-liconv" "-lSystem" "-lc" "-lm" "-L" "/Users/beeb/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/tmp/cargo-installPZzKPk/release/build/libgit2-sys-490ffd73355c0c43/build_script_build-490ffd73355c0c43" "-Wl,-dead_strip" "-nodefaultlibs"
= note: ld: library not found for -liconv
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)