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

Improve behaviour around rustfmt #217

Open
PaulOlteanu opened this issue Jan 7, 2024 · 3 comments
Open

Improve behaviour around rustfmt #217

PaulOlteanu opened this issue Jan 7, 2024 · 3 comments

Comments

@PaulOlteanu
Copy link

Hello, I'm having issues building mediasoup inside of Docker. mediasoup uses planus-codegen in their build.rs, and their build script seems to be failing here because of this with the following error:

16.46 error: failed to run custom build command for `mediasoup-sys v0.7.2`
16.46 
16.46 Caused by:
16.46   process didn't exit successfully: `/target/debug/build/mediasoup-sys-8057748db0303d06/build-script-build` (exit status: 101)
16.46   --- stderr
16.46   thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/mediasoup-sys-0.7.2/build.rs:39:14:
16.46   Failed to generate Rust code from flatbuffers: Unable to write the file to rustfmt
16.46 
16.46   Caused by:
16.46       Broken pipe (os error 32)
16.46 
16.46   Location:
16.46       /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/planus-codegen-0.4.0/src/rust/mod.rs:985:14
16.46   stack backtrace:
16.46      0: rust_begin_unwind
16.46                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
16.46      1: core::panicking::panic_fmt
16.46                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
16.46      2: core::result::unwrap_failed
16.46                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1653:5
16.46      3: core::result::Result<T,E>::expect
16.46                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1034:23
16.46      4: build_script_build::main
16.46                at ./build.rs:38:9
16.46      5: core::ops::function::FnOnce::call_once
16.46                at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
16.46   note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

This is reproducible just by creating a new Rust project, adding mediasoup = "0.15" to the dependencies, and trying to build a simple image with docker build .:

# Dockerfile
FROM rust:1.75-bookworm
COPY . .
# RUN apt update && apt install -y pip
ENV RUST_BACKTRACE=full
ENV CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true
RUN cargo build

I don't think I'll have time to help create a more minimal reproduction in the near future

Thanks

@nazar-pc
Copy link

nazar-pc commented Jan 7, 2024

I think the solution here would be to make formatting optional. In mediasoup we use planus-translation and planus-codegen in build.rs and don't care about formatting at all, we just need a valid Rust file written in OUT_DIR.

@PaulOlteanu
Copy link
Author

As @nazar-pc pointed out in versatica/mediasoup#1303, the issue was not having rustfmt installed in the container

@TethysSvensson
Copy link
Collaborator

I think we should improve the error message here and also add an option to disable formatting.

@TethysSvensson TethysSvensson changed the title planus_codegen::generate_rust fails when running in Docker Improve behaviour around rustfmt Jan 7, 2024
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