Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Doesn't work with rust-analyzer #33

Open
brainplot opened this issue May 5, 2020 · 5 comments
Open

Doesn't work with rust-analyzer #33

brainplot opened this issue May 5, 2020 · 5 comments

Comments

@brainplot
Copy link

Hi, I was looking into writing an ebuild script for rust-analyzer and use this tool to list all dependent crates, as per the Gentoo wiki.
However, I cloned their repository, ran cargo ebuild in the project root but it failed with

Error: cargo metadata failed to resolve the root package

I tried cargo ebuild with a bunch of other popular Rust repos such as ripgrep and bat; and it worked with all of them. There must be something with how the rust-analyzer code base is structured that cargo-ebuild doesn't like.

@cardoe
Copy link
Owner

cardoe commented May 5, 2020

Have you tried the --manifest-path <PATH> Path to Cargo.toml option?

@brainplot
Copy link
Author

I just tried. It still doesn't work, unfortunately.

gian@mars ~/Projects/rust-analyzer $ cargo ebuild --manifest-path Cargo.toml 
Error: cargo metadata failed to resolve the root package
gian@mars ~/Projects/rust-analyzer $ cargo ebuild 
Error: cargo metadata failed to resolve the root package

First time I ran the command it hung there for 10 to 15 seconds and then output the error message. In all subsequent retries from there, the program exists immediately but with the same error message.

@nightspc
Copy link

Works fine when given the proper path:

nightspc@hf ~/current/rust-analyzer $ cargo ebuild --manifest-path crates/rust-analyzer/Cargo.toml
Wrote: rust-analyzer-0.1.0.ebuild

There are issues with the generated ebuild since it has git-dependencies but the tool itself is works fine.

Heres a copy of the generated ebuild:
https://gist.github.com/nightspc/4fbdfabaebb026dcca9afcfea6cedcd0

And here's a copy of one I manually created by inspecting ~/.cargo:
https://gist.github.com/nightspc/d1cf6ef737b2c2a26aed18df7250b015

@cardoe
Copy link
Owner

cardoe commented May 28, 2020

@brainplot the issue is the top level Cargo.toml is a workspace definition file. That's not something that cargo metadata handles. It's merely links to other actual crates. So that's why @nightspc was able to make it work by providing the path to the actual crate.

Ultimately, cargo ebuild just wraps cargo metadata and in the future cargo build-plan once it's stable so if it doesn't work with those commands. It won't work. I'll add some notes about this to the README.

@cardoe
Copy link
Owner

cardoe commented May 28, 2020

Unfortunately github archive links aren't stable as Gentoo has discovered before. Their hashes change as github internally updates the version of git they use.

I don't have a good answer for chalk since it's a git dependency as the cargo.eclass doesn't yet support git dependencies. Once it does then cargo-ebuild can output the appropriate syntax for that.

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

3 participants