Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to find appropriate headers on Ubuntu 24.04 despite having libssl-dev installed #2217

Open
samuela opened this issue Apr 9, 2024 · 3 comments

Comments

@samuela
Copy link

samuela commented Apr 9, 2024

I'm currently seeing an error:

  cargo:warning=In file included from /usr/include/openssl/opensslv.h:109,
  cargo:warning=                 from build/expando.c:1:
  cargo:warning=/usr/include/openssl/macros.h:14:10: fatal error: openssl/opensslconf.h: No such file or directory
  cargo:warning=   14 | #include <openssl/opensslconf.h>
  cargo:warning=      |          ^~~~~~~~~~~~~~~~~~~~~~~
  cargo:warning=compilation terminated.

  --- stderr
  thread 'main' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.101/build/main.rs:186:13:

  Header expansion error:
  Error { kind: ToolExecError, message: "Command \"cc\" \"-O0\" \"-ffunction-sections\" \"-fdata-sections\" \"-fPIC\" \"-gdwarf-4\" \"-fno-omit-frame-pointer\" \"-I\" \"/usr/include\" \"-Wall\" \"-Wextra\" \"-E\" \"build/expando.c\" with args \"cc\" did not execute successfully (status code exit status: 1)." }

  Failed to find OpenSSL development headers.

  You can try fixing this setting the `OPENSSL_DIR` environment variable
  pointing to your OpenSSL installation or installing OpenSSL headers package
  specific to your distribution:

      # On Ubuntu
      sudo apt-get install libssl-dev
...

Full log available in this gist.

However I have pkg-config and libssl-dev installed and up to date:

root@6b49c5e222e1:/workspaces/sshenanigans# apt-get install pkg-config libssl-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
pkg-config is already the newest version (1.8.1-2).
libssl-dev is already the newest version (3.0.13-0ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
root@6b49c5e222e1:/workspaces/sshenanigans# 

Inspecting /usr/include, I can see that /usr/include/openssl/ has 133 header files, all the usual suspects, and /usr/include/aarch64-linux-gnu/openssl/ contains two header files: configuration.h and opensslconf.h.

For reproducibility, I'm attempting to cargo build a rust project that depends on openssl-sys from within this Docker container:

FROM ubuntu:24.04
RUN apt-get update && apt-get install -y curl libssl-dev pkg-config
# See https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#in-a-container.
RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux --init none --no-confirm
ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"
RUN nix profile install nixpkgs#cargo nixpkgs#gcc
@samuela
Copy link
Author

samuela commented Apr 9, 2024

I'm also able to reproduce the same behavior on Ubuntu 22.04

@samuela
Copy link
Author

samuela commented Apr 9, 2024

Using cargo from a rustup installation works however...

@samuela
Copy link
Author

samuela commented Apr 9, 2024

Ok, using cargo from rustup, but gcc from nixpkgs (nix profile install nixpkgs#gcc instead of apt-get install build-essential) produces the error. So I suspect something in that cc` or its configuration is at fault...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant