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

Failed to read Cargo.toml #136

Closed
blaxill opened this issue Feb 17, 2020 · 2 comments
Closed

Failed to read Cargo.toml #136

blaxill opened this issue Feb 17, 2020 · 2 comments

Comments

@blaxill
Copy link

blaxill commented Feb 17, 2020

When running raze I get the error "Failed to run cargo metadata". Running cargo metadata directly works correctly and also the project compiles correctly. I am running raze against the Cargo.toml workspace for the project, the examples/abitest/abitest_common/Cargo.toml file referenced below is a higher up in the tree.

Although it looks like the code has been around for a while it may possibly be caused by this scoped tempdir, as when TempDir is dropped it calls its close function.

Loaded override settings: RazeSettings {
    workspace_path: "//third_party/rust-crates",
    target: "x86_64-unknown-linux-gnu",
    crates: {},
    gen_workspace_prefix: "raze",
    genmode: Remote,
    output_buildfile_suffix: "BUILD",
}
`cargo metadata` failed. Inspect Cargo.toml for issues!
stdout:
stderr: error: failed to read `/tmp/cargo_raze_metadata_dir.ginDFn39u9PD/examples/abitest/abitest_common/Cargo.toml`

Caused by:
  No such file or directory (os error 2)

error: Raze failed with cause: "Failed to run `cargo metadata`"
@acmcarther
Copy link
Member

acmcarther commented Feb 17, 2020

Thank you very much for filing this bug!

#134 updated the implementation to use cargo metadata instead of the cargo internals.

Looks like this a bug in the cargo metadata codepath. For now, you can use --deprecated-use-cargo-internals to use the old codepath. I'll take a look at this again later today. If that doesn't work, please cargo-install the last version (and/or ping here and I'll expedite looking into this).

@acmcarther
Copy link
Member

I tried to reproduce this and was not successful. Here's what I tried:

  1. Create a directory tree with the following structure:
.
└── third_party
    └── rust-crates
        ├── BUILD
        ├── Cargo.toml
        ├── crates.bzl
        ├── remote
        │   ├── BUILD
        │   ├── cfg-if-0.1.10.BUILD
        │   ├── getrandom-0.1.14.BUILD
        │   ├── libc-0.2.69.BUILD
        │   ├── ppv-lite86-0.2.6.BUILD
        │   ├── rand-0.7.3.BUILD
        │   ├── rand_chacha-0.2.2.BUILD
        │   ├── rand_core-0.5.1.BUILD
        │   ├── rand_hc-0.2.0.BUILD
        │   └── wasi-0.9.0+wasi-snapshot-preview1.BUILD
        └── src
            └── main.rs
  1. $ cd third_party/rust-crates && cargo raze
Loaded override settings: RazeSettings {
    workspace_path: "//third_party/rust-crates",
    target: "x86_64-unknown-linux-gnu",
    crates: {},
    gen_workspace_prefix: "raze",
    genmode: Remote,
    output_buildfile_suffix: "BUILD",
}
Generated remote/BUILD successfully
Generated .//remote/cfg-if-0.1.10.BUILD successfully
Generated .//remote/getrandom-0.1.14.BUILD successfully
Generated .//remote/libc-0.2.69.BUILD successfully
Generated .//remote/ppv-lite86-0.2.6.BUILD successfully
Generated .//remote/rand-0.7.3.BUILD successfully
Generated .//remote/rand_chacha-0.2.2.BUILD successfully
Generated .//remote/rand_core-0.5.1.BUILD successfully
Generated .//remote/rand_hc-0.2.0.BUILD successfully
Generated .//remote/wasi-0.9.0+wasi-snapshot-preview1.BUILD successfully
Generated .//BUILD successfully

Here is what happens when I mess up the Cargo.toml (just to see the printed path):

$ cargo raze
Loaded override settings: RazeSettings {
    workspace_path: "//third_party/rust-crates",
    target: "x86_64-unknown-linux-gnu",
    crates: {},
    gen_workspace_prefix: "raze",
    genmode: Remote,
    output_buildfile_suffix: "BUILD",
}
`cargo metadata` failed. Inspect Cargo.toml for issues!
stdout: 
stderr: error: failed to parse manifest at `/tmp/cargo_raze_metadata_dir.3xNnV6dKOpQQ/Cargo.toml`

Caused by:
  no targets specified in the manifest
  either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present

error: Raze failed with cause: "Failed to run `cargo metadata`"

Hmm. I'm noticing that your error indicates that the file is expected at $TMP/examples/abitest/abitest_common/Cargo.toml while mine is expected at /Cargo.toml. Can you print your Cargo.toml (omitting anything sensitive) here?

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

2 participants