cardoe / cargo-ebuild

cargo extension that can generate ebuilds using the in-tree eclasses
Apache License 2.0
75 stars 13 forks source link

Doesn't work with rust-analyzer #33

Open brainplot opened 4 years ago

brainplot commented 4 years ago

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 commented 4 years ago

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

brainplot commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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.