-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Working directory different between cargo run and test #11852
Comments
Thanks for the report! This is intentional behavior, though I understand how it can be confusing. The reason I don't think either of these behaviors can be changed, but it seems like the documentation could be clarified. |
Thank you for getting back to me. While it still seems baffling, given the context in which I imagine most tests will be run, I'll find ways of dealing with it (at the moment, using CARGO_MANIFEST_DIR as an "invariant" which always refers to the package root does the trick). |
Hmm, maybe adding a subsection here along the lines of "Running tests in a workspace" would clarify the behaviour of |
Can you verify if We can also add a similar subsection under |
There isn't. I like the idea of linking the two sections. At first I thought that |
Also, if you find the piece of code determining that behavior, and it makes sense to add a comment there explaining it, add it please 😁 |
@rustbot claim |
I am not sure whether this should be classified as a bug...
When I use cargo run from my workspace root directory, my working directory seems to always point to the manifest dir for the top-level workspace. However, when I use cargo test from the same location, my working directory will be set to the manifest dir of the crate, whose tests are being run at the time.
This is really counter-intuitive behaviour, IMHO.
Should this not be consistent in all cases between cargo run and cargo test? Specifically, if I cargo run/test from the workspace root, it should set working directory to the workspace manifest dir. If I cargo run/test from the specific crate directory (or maybe even with the -p option), the working directory should be set to the manifest dir for that crate.
Incidentally, using the --manifest-path option doesn't seem to affect any of the above.
The text was updated successfully, but these errors were encountered: