Skip to content
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 run --path" #6142

Closed
tshepang opened this issue Oct 6, 2018 · 9 comments
Closed

"cargo run --path" #6142

tshepang opened this issue Oct 6, 2018 · 9 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@tshepang
Copy link
Member

tshepang commented Oct 6, 2018

The utility of cargo install --path makes me wish we had a cargo run --path as well... very helpful for testing functionality without needing to install. Do others have the same wish?

@crumblingstatue
Copy link

crumblingstatue commented Oct 6, 2018

Please clarify what you want to happen.
As far as I understand, cargo install --path path/to/foo/ installs crate foo from a local directory containing the source code. Do you just want to run foo without installing it? Why not just go into its local directory and do cargo run there?

Is changing directories such an inconvenience that cargo needs to do it for the user?

@alexcrichton alexcrichton added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Oct 6, 2018
@tshepang
Copy link
Member Author

tshepang commented Oct 7, 2018

It is indeed inconvenient having to change dirs just to run (a fresh) executable. Note that cargo install --path does not require you to be in same directory either.

@alexcrichton
Copy link
Member

I believe this is the --manifest-path option, does that work for you?

@tshepang
Copy link
Member Author

tshepang commented Oct 8, 2018

Actually that works, even if awkward... thanks @alexcrichton

@alexcrichton
Copy link
Member

Ok, great!

@JoKalliauer
Copy link

Is changing directories such an inconvenience that cargo needs to do it for the user?

Changing directories is an impossibility, since https://github.com/JoKalliauer/cleanupSVG/blob/master/render.sh uses different external svg2png-convertion and of them uses cargo, so the input and output-files should be kept in place (relative path) and the following renderer should be started also from the original path.

the manifest-path does not link to the path, but to the file "Cargo.toml" directly:
cargo run --manifest-path ~Documents/GitHub/resvg/Cargo.toml --release -- in.svg out.png

@elliot-u410
Copy link

elliot-u410 commented Mar 3, 2022

The --manifest-path option doesn't handle the case if there is a rust-toolchain.toml file that needs to be used. Is there a way to specify that too?

Really, I think there needs to be a --path option to cargo run so that it can be invoked from any directory. It is particularly helpful when scripting and proxying commands to a cargo project that you want to build lazily.

@ryankurte
Copy link

i think this also comes up when you're cross compiling packages, --manifest-path gets you into the directory but .cargo/config seems to still be loaded from wherever the command is executed (rather than from within the package)

@epage
Copy link
Contributor

epage commented Jul 30, 2022

For .cargo/config see also #2930. One workaround that has been talked about is #10098 but that would mean the program wouldn't be running from the desired CWD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

7 participants