Description
originally discovered in #13553
Bevy version
0.14.0
Relevant system information
- Rust version: 1.80.0
- OS: Windows 11
`AdapterInfo { name: "NVIDIA GeForce GTX 1080 Ti", vendor: 4318, device: 6918, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "555.99", backend: Vulkan }`
What you did
Cargo.toml
[package]
name = "minimal_doctest_fail"
version = "0.1.0"
edition = "2021"
[dependencies]
# remove the `dynamic_linking` feature to fix the issue.
bevy = { version = "0.14.0", features = ["dynamic_linking"] }
# Enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1
# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev.package."*"]
opt-level = 3
lib.rs
/// ```
/// use bevy::prelude::*;
/// ```
pub struct Foo;
What went wrong
Running cargo test --doc
results in a failure:
Test executable failed (exit code: 0xc0000135)
That exit code means that a dynamic library was not found. Indeed, removing the dynamic_linking
feature fixes this.
Additional information
Quoting @SkiFire13 here:
@janhohenheim I can confirm that this results in the
Test executable failed (exit code: 0xc0000135)
error for me as well (tested with an empty.cargo/config.toml
and noRUSTFLAGS
orRUSTDOCFLAGS
set).I've also managed to further minimize the issue to remove the dependency on Bevy. You only need a crate depending on a
dylib
crate, and a doctest that uses any item from thedylib
crate. SkiFire13/minimal_dylib_doctest_failI've also found this rust issue which seems to fit the problem rust-lang/rust#39487. It has been closed in favour of rust-lang/rustup#893, where it's mentioned that the issue is with the stdilb dll not being added to the path when running the test. Indeed if I either add
%RUSTUP_HOME%\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\
to thePATH
or copy thestd-****.dll
file in that directory to the directory where I'm runningcargo test --doc
then it works. However I wonder why this issue doesn't appear on Linux (I've tested on WSL and the same minimalized reproduction works fine without the workaround).
Since this breaks doctests for Windows users following Bevy's recommended settings, we should probably make readers aware of this. I opened bevyengine/bevy-website#1522 to add a little mention to the dynamic-on-Windows disclaimer we have anyways.