google / cargo-raze

Generate Bazel BUILD from Cargo dependencies!
Apache License 2.0
480 stars 104 forks source link

Parsing of workspace members paths broken on Windows #360

Closed stevenlr closed 3 years ago

stevenlr commented 3 years ago

I tried upgrading my project from 0.6.1 to 0.9.1 but ran into an issue:

Error: The regex pattern `.+\(path\+file://(.+)\)` found a path that did not contain a Cargo.toml file: `/C:/Users/steve/Desktop/Callisto`

From what I've seen, this is caused by the fact that cargo metadata has an extra slash than what is expected by the regex (at least on Windows) .

Result of cargo metadata

//...
    "workspace_members": [
        "compile_with_bazel 0.0.0 (path+file:///C:/Users/steve/Desktop/Callisto)"
    ],
//...

From impl/src/metadata.rs:

let crate_member_id_re = Regex::new(r".+\(path\+file://(.+)\)")?;

Since the following code simply appends Cargo.toml to the capture of this regex and checks for the existence of this file, the erronous path (/C:/Users/steve/Desktop/Callisto/Cargo.toml) is generated, and the file cannot be found at this location.

RexMagi commented 3 years ago

Hey, I just submitted a PR for this I have also been seeing this issue. A good workaround I have been successful with has been to use WSL instead of running it directly in windows. it looks like there might be some other bugs in windows though.

stevenlr commented 3 years ago

Thank you, I just tested it and it's ok now. I'm closing this.