-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
cargo test --doc not load same shared libraries as cargo test --lib #8531
Comments
For what it's worth, I'm seeing the same issue running doctests against my library that uses SDL2 (https://github.com/Rust-SDL2/rust-sdl2). |
Same problem with any OS + rust1.48+, but not with rust1.42. |
Using |
This is still broken on 1.58 |
Fixes rust-lang#8531. This issue was introduced by 3fd2814. Prior to that commit, the `rustdoc_process` function took other branch of the if statement being modified by this commit. The flag was previously called `is_host`, and `rustdoc` was run reporting `false`. In that commit, the flag was changed to `is_rustc_tool`, and rustdoc began reporting `true`, which resulted in the native directories added by build scripts no longer being appended to LD_LIBRARY_PATH when running doctests. This commit changes the behavior so that we are always appending the same set of paths, and the only variance is if we are cross compiling or not. An alternative would be to change rustdoc to always pass `kind: CompileKind::Host, is_rustc_tool: false`, but as rustdoc is in fact a rustc tool, that feels wrong. The commit which introduced the bug did not include context on why the flag was changed to `is_rustc_tool`, so I don't have a sense for if we should just change that flag to mean something else. While the test suite previously had an explicit test for the library path behavior of `cargo run`, it did not test this for various test forms. This commit modifies the test to ensure the behavior is consistent across `run`, normal tests, and doctests.
This issue is known for almost 3 years, could you give us a timeline when a fix will come? Not knowing about this I just wasted hours trying to find out why my doc tests fail :( |
Is there a workaround for this issue? Update: |
@adamcrume do you have any clue what might have caused this bug? Is @alexcrichton still around? Iirc he was stepping down from several Rust projects, but not cargo. |
I don't know what specifically in 3fd2814 caused this. I'm not familiar with the cargo codebase. |
We appreciate Alex efforts on Cargo and Alex has already retired from the Cargo Team.1 There was a previous attempt #10469 and concerns were listed #10469 (comment). Feel free to pick it up and continue. Footnotes |
@weihanglo with all due respect, the concerns you linked do not point towards a, obvious, clear path forward how this issue should be remediated. I do understand you rely on others to help you fix bugs, but a community can do that with reasonable efficacy only if it is crystal clear how things should work. The concerns you listed are referenced and thought through, but they don't enable outsiders to grasp how you'd want things to be done. This bug is a problem for the Rust ecosystem. I'd love to recommend Rust more strongly in industrial projects, but this is one of the reasons why I cannot. The cargo team has broken the test coverage for all crates that include native dylibs, and some crates have responded by disabling their doctests with @ehuss I hate to be nagging, but at which point in time will the cargo team fix this issue, if no volunteers are able to address it in a way you'd accept it? How do you select which bug fixes are scheduled for a new cargo release? |
In some system, `cargo test --doc` may fail due to the bug: rust-lang/cargo#8531
Looks as though no one is looking at this. I'm new to the code, but this seems approachable to me. I'll take a wack if it's really open. |
Problem
cargo test --doc
doesn't appear to be loading the same shared libraries ascargo test --lib
in 1.45Steps
cargo test --doc
andcargo test --lib
passcargo test --lib
passes butcargo test --doc
fails witherror while loading shared libraries: libtensorflow.so.1: cannot open shared object file: No such file or directory
Notes
Output of
cargo version
:cargo 1.44.0 (05d080f 2020-05-06) or cargo 1.45.0 (744bd1f 2020-06-15)
Running on Ubuntu 20.04 LTS.
The text was updated successfully, but these errors were encountered: