Skip to content

cargo fmt doesn't accept --manifest-path #2817

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
epage opened this issue Jun 29, 2018 · 5 comments · Fixed by #3683
Closed

cargo fmt doesn't accept --manifest-path #2817

epage opened this issue Jun 29, 2018 · 5 comments · Fixed by #3683
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@epage
Copy link
Contributor

epage commented Jun 29, 2018

I ran into this today when trying to integrate rust with a proprietary toolchain. I was finding it easier to not change my CWD and was instead explicitly passing --manifest-path but cargo fmt doesn't accept it.

@topecongiro
Copy link
Contributor

Could you try passing --package instead?

@epage
Copy link
Contributor Author

epage commented Jun 30, 2018

Both fail:

cargo fmt --package source\rust_test\Cargo.toml -- --write-mode=diff
cargo fmt --package source\rust_test -- --write-mode=diff
``
with an error about `cargo manifest` failing

I originally passed over `--package` because I was looking for `--manifest-path` but also when browsing the help, the part about workspaces made me think it didn't apply to me.
-p, --package <package>
                    specify package to format (only usable in workspaces)

Also should mention: "rustfmt 0.6.1-stable (49279d71 2018-05-08)"

@epage
Copy link
Contributor Author

epage commented Jun 30, 2018

Looks like pretty much every time cargo metadata is called, None is passed in as the manifest path

https://github.com/rust-lang-nursery/rustfmt/blob/master/src/cargo-fmt/main.rs#L234

@corasaurus-hex
Copy link
Contributor

I'm having this same problem.

@corasaurus-hex
Copy link
Contributor

It looks like clippy and run still support the --manifest-path argument.

$ 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.
~
$

I ran into this because the spacemacs rust layer relies on it. More specifically, cargo.el.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants