comprehensive-rust icon indicating copy to clipboard operation
comprehensive-rust copied to clipboard

xtask install-tools command requires being in root directory of project

Open egithinji opened this issue 10 months ago • 2 comments

Via #2688 we can now install the dependent project tools with one cross platform command cargo xtask install-tools. The command fails to install mdbook-exerciser and mdbook-course however unless you are in the root of the repository. This is because these two dependencies are located in the local filesystem.

One of the benefits of the cargo xtask approach is we can run commands from anywhere so it would be nice if this could be fixed somehow.

egithinji avatar Apr 06 '25 14:04 egithinji

How about using the environment variable CARGO_MANIFEST_DIR. That one is always set to the xtask directory and is a known anchor in the filesystem.

This would in the end be something along the lines of format!("{}/../mdbook-course", env::var("CARGO_MANIFEST_DIR")?). I don't see any useful environment variable for the workspace directory but maybe there is.

michael-kerscher avatar Apr 07 '25 08:04 michael-kerscher

Yes, I was also thinking along these exact lines. I think this approach should work for our use case.

egithinji avatar Apr 07 '25 09:04 egithinji