Skip to content

Cargo fmt no longer supports --manifest-path #6024

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

Closed
corasaurus-hex opened this issue Sep 14, 2018 · 6 comments
Closed

Cargo fmt no longer supports --manifest-path #6024

corasaurus-hex opened this issue Sep 14, 2018 · 6 comments

Comments

@corasaurus-hex
Copy link

corasaurus-hex commented Sep 14, 2018

It seems like cargo fmt ought to support --manifest-path but it seems to be broken from what I can tell: rust-lang/rustfmt#2817

This is using cargo 1.29.0 (524a578d7 2018-08-05) and rustfmt 0.99.1-stable (da17b689 2018-08-04).

@corasaurus-hex
Copy link
Author

corasaurus-hex commented Sep 14, 2018

Specifically:

$ cargo run --manifest-path Code/exercism/rust/saddle-points/Cargo.toml
error: a bin target must be available for `cargo run`
~
$ cargo clippy --manifest-path Code/exercism/rust/saddle-points/Cargo.toml
    Checking saddle-points v1.3.0 (file:///Users/nsutton/Code/exercism/rust/saddle-points)
error: expected expression, found `)`
  --> src/lib.rs:13:9
   |
13 |         );
   |         ^ expected expression

error: aborting due to previous error

error: Could not compile `saddle-points`.

To learn more, run the command again with --verbose.
~
$ cargo fmt --manifest-path Code/exercism/rust/saddle-points/Cargo.toml
Invalid argument: `Code/exercism/rust/saddle-points/Cargo.toml`.
usage: cargo fmt [options]

Options:
    -h, --help          show this message
    -q, --quiet         no output printed to stdout
    -v, --verbose       use verbose output
    -p, --package <package>
                        specify package to format (only usable in workspaces)
        --version       print rustfmt version and exit
        --all           format all packages (only usable in workspaces)

This utility formats all bin and lib files of the current crate using rustfmt. Arguments after `--` are passed to rustfmt.
~
$

See how cargo fmt sees it as an invalid argument?

@ehuss
Copy link
Contributor

ehuss commented Sep 14, 2018

I don't think this is a cargo issue. rustfmt ships the cargo-fmt command. It needs to be updated as described in the linked rustfmt issue.

@corasaurus-hex
Copy link
Author

Yeah, seems like the issue is in cargo-fmt in rustfmt. Do you mean updated as in to use the package option? I don't think that applies here.

@ehuss
Copy link
Contributor

ehuss commented Sep 14, 2018

cargo-fmt would need to be updated to add a --manifest-path option (probably somewhere in here), and then it would need to pass the path into get_cargo_metadata in this file where it currently passes None.

@corasaurus-hex
Copy link
Author

Cool, thanks for the tips. I'm trying to put together my first patch for a rust project. :) rust-lang/rustfmt@master...nate:accept-manifest-path

@dwijnand
Copy link
Member

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants