Cannot build with Rust on Windows

Hello,

This happens specifically with Rust on Windows, I have all the requirements as I also tried with the npm package, which compiles with no issues.

edit: I still had to call “C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat” in a cmd and reuse that cmd before building, otherwise npm install would fail
Tested on different machines with W10 and W11 with exact same result

Here is the full stacktrace I get

 Found ninja.exe-1.10.2.git.kitware.jobserver-1 at C:/Users/jeje_/Desktop/Vox-2.0/server/target/debug/build/mediasoup-sys-c89d62f62e531964/out/out/pip/bin/ninja.exe
  WARNING: msvc does not support C++11; attempting best effort; setting the standard to C++14

  --- stderr

  Usage:
    c:\Users\jeje_\AppData\Local\Programs\Python\Python311\python.exe -m pip install [options] <requirement specifier> [package-index-options] ...
    c:\Users\jeje_\AppData\Local\Programs\Python\Python311\python.exe -m pip install [options] -r <requirements file> [package-index-options] ...
    c:\Users\jeje_\AppData\Local\Programs\Python\Python311\python.exe -m pip install [options] [-e] <vcs project url> ...
    c:\Users\jeje_\AppData\Local\Programs\Python\Python311\python.exe -m pip install [options] [-e] <local project path> ...
    c:\Users\jeje_\AppData\Local\Programs\Python\Python311\python.exe -m pip install [options] <archive url/path> ...

  no such option: --system
  Directory does not contain a valid build tree:
  C:\Users\jeje_\Desktop\Vox-2.0\server\target\debug\build\mediasoup-sys-c89d62f62e531964\out\out\Release\build
  /c/Users/jeje_/.cargo/registry/src/github.com-1ecc6299db9ec823/mediasoup-sys-0.5.4/scripts/cpu_cores.sh: line 9: nproc: command not found
  ninja: error: manifest 'build.ninja' still dirty after 100 tries

  "make": *** [libmediasoup-worker] Error 1
  thread 'main' panicked at 'Failed to build libmediasoup-worker', C:\Users\jeje_\.cargo\registry\src\github.com-1ecc6299db9ec823\mediasoup-sys-0.5.4\build.rs:96:9
  stack backtrace:
     0:     0x7ff6ee0eb072 - std::backtrace_rs::backtrace::dbghelp::trace
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
     1:     0x7ff6ee0eb072 - std::backtrace_rs::backtrace::trace_unsynchronized
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
     2:     0x7ff6ee0eb072 - std::sys_common::backtrace::_print_fmt
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\sys_common\backtrace.rs:65
     3:     0x7ff6ee0eb072 - std::sys_common::backtrace::_print::impl$0::fmt
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\sys_common\backtrace.rs:44
     4:     0x7ff6ee103d9b - core::fmt::write
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\core\src\fmt\mod.rs:1208
     5:     0x7ff6ee0e77aa - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\io\mod.rs:1682
     6:     0x7ff6ee0eadbb - std::sys_common::backtrace::_print
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\sys_common\backtrace.rs:47
     7:     0x7ff6ee0eadbb - std::sys_common::backtrace::print
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\sys_common\backtrace.rs:34
     8:     0x7ff6ee0edb99 - std::panicking::default_hook::closure$1
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\panicking.rs:267
     9:     0x7ff6ee0ed81b - std::panicking::default_hook
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\panicking.rs:286
    10:     0x7ff6ee0ee431 - std::panicking::rust_panic_with_hook
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\panicking.rs:688
    11:     0x7ff6ee0ee17b - std::panicking::begin_panic_handler::closure$0
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\panicking.rs:577
    12:     0x7ff6ee0ebd6f - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\sys_common\backtrace.rs:137
    13:     0x7ff6ee0ede70 - std::panicking::begin_panic_handler
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\panicking.rs:575
    14:     0x7ff6ee109ec5 - core::panicking::panic_fmt
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\core\src\panicking.rs:64
    15:     0x7ff6ee0d82d5 - build_script_build::main
                                 at C:\Users\jeje_\.cargo\registry\src\github.com-1ecc6299db9ec823\mediasoup-sys-0.5.4\build.rs:96
    16:     0x7ff6ee0d39db - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405\library\core\src\ops\function.rs:507
    17:     0x7ff6ee0d535e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405\library\std\src\sys_common\backtrace.rs:121
    18:     0x7ff6ee0d535e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405\library\std\src\sys_common\backtrace.rs:121
    19:     0x7ff6ee0d7a41 - std::rt::lang_start::closure$0<tuple$<> >
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405\library\std\src\rt.rs:166
    20:     0x7ff6ee0e437e - core::ops::function::impls::impl$2::call_once
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\core\src\ops\function.rs:606
    21:     0x7ff6ee0e437e - std::panicking::try::do_call
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\panicking.rs:483
    22:     0x7ff6ee0e437e - std::panicking::try
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\panicking.rs:447
    23:     0x7ff6ee0e437e - std::panic::catch_unwind
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\panic.rs:137
    24:     0x7ff6ee0e437e - std::rt::lang_start_internal::closure$2
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\rt.rs:148
    25:     0x7ff6ee0e437e - std::panicking::try::do_call
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\panicking.rs:483
    26:     0x7ff6ee0e437e - std::panicking::try
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\panicking.rs:447
    27:     0x7ff6ee0e437e - std::panic::catch_unwind
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\panic.rs:137
    28:     0x7ff6ee0e437e - std::rt::lang_start_internal
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library\std\src\rt.rs:148
    29:     0x7ff6ee0d7a1a - std::rt::lang_start<tuple$<> >
                                 at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405\library\std\src\rt.rs:165
    30:     0x7ff6ee0d8dc9 - main
    31:     0x7ff6ee10868c - invoke_main
                                 at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
    32:     0x7ff6ee10868c - __scrt_common_main_seh
                                 at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    33:     0x7ff88f347614 - BaseThreadInitThunk
    34:     0x7ff88f6226a1 - RtlUserThreadStart

From what I understand the pip error “no such option: --system” is normal on windows and does not prevent build… ?

However “Directory does not contain a valid build tree:” seems to the critical issue, from what I could gather it’s related to meson

Also not really sure about nproc

I tried investigating however I could. Ninja is unable to compile.
ninja logs:

# ninja log v5
1	7192	6978946387934553	build.ninja	5b15d53c9701d67a
1	6793	6978946387934553	build.ninja	5b15d53c9701d67a

It seems that meson is calling every few seconds this command:

[0/1] "C:\Users\jeje_\Desktop\Vox-2.0\server\target\debug\build\mediasoup-sys-c89d62f62e531964\out\out\pip\bin\meson" "--internal" "regenerate" "C:\Users\jeje_\.cargo\registry\src\github.com-1ecc6299db9ec823\mediasoup-sys-0.5.4" "C:\Users\jeje_\Desktop\Vox-2.0\server\target\debug\build\mediasoup-sys-c89d62f62e531964\out\out\Release\build" "--backend" "ninja"

No error in the meson-logs.txt beyond the mention of the dirty build.

I tried modifying the makefile in the registry crate to enable more verbose logging, but I was unsuccesful. (meson compile -C --verbose… ?)
Any help would be appreciated.

Thanks

Probably requires installation of unix compatible commands such as msys2
However, even after fixing this, I encountered a path limit error and I quickly gave up trying to solve it.

  ninja: error: Stat(subprojects/usrsctp-4e06feb01cadcd127d119486b98a4bd3d64aa1e7/libusrsctp.a.p/C__Users_runneradmin_.cargo_registry_src_index.crates.io-6f17d22bba15001f_mediasoup-sys-0.5.4_subprojects_usrsctp-4e06feb01cadcd127d119486b98a4bd3d64aa1e7_usrsctplib_user_environment.c.obj): Filename longer than 260 characters

For some reason, building with rust creates a longer path than building with node.