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

Cargo metadata subcommand should work with workspaces #3003

Closed
matklad opened this issue Aug 16, 2016 · 10 comments
Closed

Cargo metadata subcommand should work with workspaces #3003

matklad opened this issue Aug 16, 2016 · 10 comments

Comments

@matklad
Copy link
Member

matklad commented Aug 16, 2016

Currently it gives

error: manifest path `/home/matklad/projects/vulkano/Cargo.toml` is a virtual manifest, but this command requires running against an actual package in this workspace

Ideally it should return the info in the same format as metadata command for the non-virtual manifest. The only obstacle seems to be the root node in the resolve.

And perhaps for any package that is a part of the workspace cargo metadata should indicate it.

@matklad
Copy link
Member Author

matklad commented Aug 17, 2016

Ok, so to solve this we need to get rid of the root field in the Resolve structure. It is not used in a significant way during resolve procedure and basically just duplicates Workspace::current.

Also, we currently serialize arbitrary root into the lockfile. It should be possible to get rid of this in a backwards compatible way.

@matklad
Copy link
Member Author

matklad commented Aug 17, 2016

Note: check_cycles in the resolver may be buggy because it currently only checks for cycles in sub graph reachable from the root.

@alexcrichton
Copy link
Member

Note that unfortunately we can't get rid of root in the lockfile (and transitively Resolve), but it's fine to just ignore it and not really treat it as the "root" any more. Seems reasonable to me that this'd be expected to work!

@matklad
Copy link
Member Author

matklad commented Aug 17, 2016

Note that unfortunately we can't get rid of root in the lockfile (and transitively Resolve)

But why? What are the reasons besides backwards compatibility?

@alexcrichton
Copy link
Member

No reason beyond backwards compatibility. The thinking is that older Cargo instances should be able to work with newer lock files wherever possible.

@matklad
Copy link
Member Author

matklad commented Aug 17, 2016

But we don't use root from the Resolve when we are writing a lock file: https://github.com/rust-lang/cargo/blob/master/src/cargo/core/resolver/encode.rs#L279-L281.

So it should be possible to remove it?

@matklad
Copy link
Member Author

matklad commented Aug 17, 2016

That is, remove from the Resolve struct, not from the lockfile of course (though we can accept lockfiles without root to be able to delete it later).

@alexcrichton
Copy link
Member

Oh! We should totally do that if we can!

@matklad
Copy link
Member Author

matklad commented Aug 27, 2016

And is there any way to get the list of workspace members? Perhaps this should be a part of cargo metadata json?

We don't need this in IntelliJ Rust yet, but it seems to be generally useful.

@alexcrichton
Copy link
Member

Oh yeah certainly, I believe you can iterate over packages with ws.members()

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