Skip to content

Working directory different between cargo run and test #11852

@dkorsunsky

Description

@dkorsunsky

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions