Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Specify –manifest-path while using cargo watch

A fantastic crate is cargo watch, which allows, for example, for you to execute:

cargo watch -x run

to automatically rebuild/run on src change. This is amazing for development but one issue I have is that it seems to not support the --manifest-path argument that can be used with cargo run to explicitly specify the path to the .toml file of the project such that it can be run from a different pwd than the Cargo.toml file itself:

cargo run --manifest-path /home/user/project/Cargo.toml

The crate documentation doesn’t mention anything about this, so I was wondering if anyone who uses this crate has found a way around this. When attempting to use the --manifest-path argument I receive:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

error: Found argument '--manifest-path' which wasn't expected, or isn't valid in this context

USAGE:
    cargo watch [FLAGS] [OPTIONS]

Which makes some sense as I know not all commands support the --manifest-path arg, but since the crate uses cargo run to run the project itself I’m guessing there is some way around this without using e.g. sh -c 'cd [path to .toml file] && cargo watch -x run'

>Solution :

Yes you can just use the invocation which lets you run arbitrary commands:

cargo watch -- cargo run --manifest-path=path/to/Cargo.toml
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading