Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Running cargo rerast in workspaces fails #39

Open
jugglerchris opened this issue Dec 2, 2019 · 5 comments
Open

Running cargo rerast in workspaces fails #39

jugglerchris opened this issue Dec 2, 2019 · 5 comments

Comments

@jugglerchris
Copy link
Contributor

I was trying to replace r#try!(...) with ...? in a project which happens to be inside a workspace.

I've put an example here:

https://github.com/jugglerchris/temp_rerast_workspace_bug

Running cargo +nightly-2019-05-13 rerast --rules_file=rtry.rs --diff from inside crates/rerast_test inside that repo just outputs:

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


If I rename the Cargo.toml in the workspace root to Cargo.toml_, then it works.

@davidlattimore
Copy link
Contributor

#33 might be relevant. It looks, based on the nightly version that you're using that you're on a very old version of rerast. That's possibly to avoid the bug mentioned in #30, but that bug has been fixed. If possible, perhaps try updating to the latest nightly and rerast. Rerast v0.1.77 was released yesterday which should work with nightly-2019-12-01 (and probably later).

@jugglerchris
Copy link
Contributor Author

Hi,
Sorry for the delay in replying.
I've updated to 0.1.77 (via cargo +nightly install rerast --force), having also done a rustup update nightly and the same still happens.
Currently nightly version:

$ rustc +nightly --version
rustc 1.41.0-nightly (ff15e9670 2019-12-13)

jugglerchris added a commit to jugglerchris/rerast that referenced this issue Dec 14, 2019
When looking for the workspace root, the match:

```rust
 if let JsonValue::String(s) = &metadata()?["workspace_root"]
```

was not succeding as the value was actually `JsonValue::Short(...)`,
an alternative string representation.

Switch to calling `JsonValue`'s `as_str()` method and matching on
the result, which should work in both cases.
@jugglerchris
Copy link
Contributor Author

I found the problem - it wasn't working when the workspace_root came back as JsonValue::Short(...) instead of JsonVale::String(...). PR submitted.

One related question - the path to the rules file has to be relative to the workspace root rather than current directory, since it chdir()s into there. Is that intentional? (It wasn't what I expected)

davidlattimore pushed a commit that referenced this issue Dec 16, 2019
When looking for the workspace root, the match:

```rust
 if let JsonValue::String(s) = &metadata()?["workspace_root"]
```

was not succeding as the value was actually `JsonValue::Short(...)`,
an alternative string representation.

Switch to calling `JsonValue`'s `as_str()` method and matching on
the result, which should work in both cases.
@davidlattimore
Copy link
Contributor

Thanks fo the fix! Just noticed your question. I don't think that was intentional. You're right that the current directory would make more sense. Feel free to send a PR to fix it if you like.

@jugglerchris
Copy link
Contributor Author

Sure - submitted.

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

No branches or pull requests

2 participants