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

Using protoc-bin-vendored doesn't work when building on NixOS #13

Open
aeblyve opened this issue Apr 20, 2024 · 2 comments
Open

Using protoc-bin-vendored doesn't work when building on NixOS #13

aeblyve opened this issue Apr 20, 2024 · 2 comments

Comments

@aeblyve
Copy link

aeblyve commented Apr 20, 2024

NixOS is a Linux distribution which does not obey the FHS, and as such, the protoc supplied by protoc-bin-vendored-linux will fail to run:

error: failed to run custom build command for `meshtastic v0.1.6`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/home/ablyve/my/83e_meshtastic-bot/target/debug/build/meshtastic-bf53c0c18fbe98d1/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=src/protobufs/

  --- stderr
  thread 'main' panicked at /home/ablyve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/meshtastic-0.1.6/build.rs:49:54:
  called `Result::unwrap()` on an `Err` value: Custom { kind: NotFound, error: "failed to invoke protoc (hint: https://docs.rs/prost-build/#sourcing-protoc): (path: \"/home/ablyve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/protoc-bin-vendored-linux-x86_64-3.0.0/bin/protoc\"): No such file or directory (os error 2)" }

If we run the binary manually:

/home/ablyve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/protoc-bin-vendored-linux-x86_64-3.0.0/bin/protoc
bash: /home/ablyve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/protoc-bin-vendored-linux-x86_64-3.0.0/bin/protoc: cannot execute: required file not found

As a workaround, doing this patchelf manually on NixOS lets the build finish:

patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) /home/ablyve/.cargo/registry/src/index.crates.io-6f17d22bba15001f/protoc-bin-vendored-linux-x86_64-3.0.0/bin/protoc

@krant
Copy link

krant commented Apr 30, 2024

Same thing on Alpine Linux - provided protoc binary expects /lib64 to be present. It is unfortunate that tokio-rs/prost#771 got stalled - downloading precompiled binary is a terrible solution and Rust ecosystem deserves better.

@Princemachiavelli
Copy link

I think the issue is the installation of the vendored protoc is successful so even if PROTOC is already set to use the Nix provided version, the build.rs will always replace the environment variable even if already set.

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

3 participants