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

Incorrect [root] in Cargo.lock when using workspaces #3203

Closed
debris opened this issue Oct 17, 2016 · 7 comments
Closed

Incorrect [root] in Cargo.lock when using workspaces #3203

debris opened this issue Oct 17, 2016 · 7 comments

Comments

@debris
Copy link
Contributor

debris commented Oct 17, 2016

I have a project with several (10+) local libraries

…
├── Cargo.toml
├── src
├── sub1
│   ├── Cargo.toml
│   ├── src
├── sub2
│   ├── Cargo.toml
│   ├── src

My Cargo.toml looks like this.

[project]
name = "foo"
version = "0.1.0"
authors = []

[dependencies]
sub1 = { path = "sub1" }
sub2 = { path = "sub2" }

After adding [workspace] to the end of Cargo.toml

[project]
name = "foo"
version = "0.1.0"
authors = []

[dependencies]
sub1 = { path = "sub1" }
sub2 = { path = "sub2" }

[workspace]

All of my dependencies compile as a part of my workspace (as expected). But what's strange, foo is no longer a [root] in my Cargo.lock file. Instead sub1 is. Is it intended behaviour?

@alexcrichton
Copy link
Member

Indeed! The [root] in Cargo.lock is basically just backwards compatibility at this point. We essentially just had to deterministically choose a crate to go there. Shouldn't affect any usage of Cargo though!

@debris
Copy link
Contributor Author

debris commented Oct 18, 2016

Shouldn't affect any usage of Cargo though!

That's right. It only affects one of the tools I'm using - cargo-graph.
I've created the issue over there. kbknapp/cargo-graph#33

@alexcrichton
Copy link
Member

Ok, thanks!

@behnam
Copy link
Contributor

behnam commented Jun 22, 2017

@alexcrichton, was there any reason to not use the workspace root as the lock root, at least for cases where workspace Cargo.toml is combined with a package? If not, is it still possible to make this happen, or is it too late?

At the moment, there's no way to find the workspace root looking only at the lock file, which is kind of unexpected and demands extra work for tools, like cargo-graph, to figure it out.

@alexcrichton
Copy link
Member

Unfortunately that'd make a backwards incompatible change at this point :(

@remram44
Copy link

Honestly I think the [root] should either be removed or fixed. There is no point keeping it "for compatibility" if compatibility has been broken. Either cargo-graph shouldn't use this (but why not use this if it's present?) or the correct info should be written to Cargo.lock.

@remram44
Copy link

After #4571, Cargo no longer includes [root] in the lock file. This makes cargo-graph even more broken. (I have updated my patch)

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

4 participants