Setting OPENSSL_DIR how exactly. .

Good day!

I’m trying to contribute to Pijul but I have to install it first. I’ve installed rustup, beta, openssl, clang, pkg-config. Just when I thought I’d finally be able to install it, I was met with this message:

error: failed to run custom build command for `openssl-sys v0.9.58`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installS6cAs3/release/build/openssl-sys-2f5335953d625928/build-script-main` (exit code: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
  X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit code: 1\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"

  --- stderr
  thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = x86_64-unknown-linux-gnu
  $TARGET = x86_64-unknown-linux-gnu
  openssl-sys = 0.9.58

  ', /home/cateroxl/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.58/build/find_normal.rs:157:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `pijul v1.0.0-alpha.9`, intermediate artifacts can be found at `/tmp/cargo-installS6cAs3`

Caused by:
  build failed

I tried finding something like libssl-dev and openssl-devel for NixOs, but there’s none. I’m really not sure what to do from this point onward because I also don’t know how to set OPENSSL_DIR environment variable. :sweat:

Please advise, I’d really appreciate. Many thanks!

Also wow, the live preview is awesome.

Looks like you’re trying to build Pijul manually.

You should be able to find the openssl dir with which -s openssl. On my system, it shows me this:

which -s openssl
/home/mchrist/.nix-profile/bin/openssl -> /nix/store/wp81dnxgrpi4lgy20r82kfg9nwrmypkm-openssl-1.1.1g-bin/bin/openssl

You could set your OPENSSL_DIR env var to the /nix/store folder.

Another approach would be to build Pijul with Nix. There’s already a package available in Nixpkgs. I imagine you could use something similar and point the source to your local development folder instead of pulling the rust crate, you could use overrideAttrs to adjust just the src attribute of that derivation…

 nix-shell '<nixpkgs>' -A pijul

This should give you a build environment for the currently package pijul in your nixpkgs?.

I’m going about doing it this way and I’ve run into:

thread 'main' panicked at 'OpenSSL include directory does not exist: /nix/store/j7kaa5ja1998wjbnj8rjks7d3574ppy9-openssl-3.0.8-bin/bin/openssl/include', /home/chrisobrien/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.87/build/main.rs:86:9

I’m using rust, trying to build a dev branch for a colleague.

You shouldn’t need to set OPENSSL_LIB anymore, adding openssl to buildInputs and pkg-config to nativeBuildInputs in your derivation should work. And if you are using a dev shell, you might also want to set LD_LIBRARY_PATH = lib.makeLibararyPath [ openssl ];

Could you elaborate more on this? Do I set this in configuration.nix?

In your dev shell preferably

I am new to shell.nix or dev shells in general, even new to nixos and nix.

in your shell.nix, you can have something like this

mkShell {
  # ...
  nativeBuildInputs = [ pkg-config ];
  buildInputs = [ openssl ];
  LD_LIBRARY_PATH = lib.makeLibararyPath [ openssl ];
}

Thx, might you be able to help on why my rust analyzer keeps acting up over it not finding openssl?

did you run rust analyzer inside the dev shell?

How would I do that? I use vscodium

Wait, I might know how