crate2nix icon indicating copy to clipboard operation
crate2nix copied to clipboard

Can't fetch git dependency that is a workspace

Open JonathanLorimer opened this issue 3 years ago • 9 comments

I am getting this error, and I think it is because the git dependency that is being fetched is a workspace. Here is the dependency that is being fetched https://github.com/informalsystems/modelator. This is the Cargo.toml is failing when I call generatedCargoNix on this workspace

Error: while retrieving metadata about ./Cargo.toml: Error during execution of `cargo metadata`: error:
 failed to get `anomaly` as a dependency of package `ibc v0.6.0 (/build/source/modules)`

Caused by:
  failed to load source for dependency `anomaly`

Caused by:
  Unable to update registry `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to update replaced source registry `https://github.com/rust-lang/crates.io-index`

Caused by:
  found a virtual manifest at `/nix/store/pd6m24q5jz3i3csxlm0gppwjkgqicg06-deps/a08p33ghcl1dix9c96i1dpgd9g8wqdda-modelator-0.1.0/Cargo.toml` instead of a package manifest

crate2nix failed.
== cargo/config (BEGIN)
    [source.crates-io]
    replace-with = "vendored-sources"

    [source."https://github.com/informalsystems/modelator"]
    git = "https://github.com/informalsystems/modelator"
    rev = "99f656fa8b3cf46a2aa0b6513e4e140d1778c4bd"

    replace-with = "vendored-sources"


    [source.vendored-sources]
    directory = "/nix/store/pd6m24q5jz3i3csxlm0gppwjkgqicg06-deps"

== cargo/config (END)

== crate-hashes.json (BEGIN)
    {"modelator 0.1.0 (git+https://github.com/informalsystems/modelator?rev=99f656fa8b3cf46a2aa0b6513e4e140d1778c4bd#99f656fa8b3cf46a2aa0b6513e4e140d1778c4bd)":"8532d146bd6d80f31e12285ebb7938e340226f7066a52deb4db126b16fc57ec8"}
== crate-hashes.json (END)

JonathanLorimer avatar Jul 16 '21 19:07 JonathanLorimer

Okay, after doing some more digging this got even weirder. If I just use crate2nix generate from within the directory, everything works as expected. Are there any notable differences between invokign crate2nix generate directly and using generatedCargoNix ?

JonathanLorimer avatar Jul 17 '21 18:07 JonathanLorimer

If it helps at all, the crate-hashes.json created by the generatedCargoNix is different from the crate-hashes.json generated when I call crate2nix generate

generatedCargoNix

{
"modelator 0.1.0 (git+https://github.com/informalsystems/modelator?rev=99f656fa8b3cf46a2aa0b6513e4e140d1778c4bd#99f656fa8b3cf46a2aa0b6513e4e140d1778c4bd)":"8532d146bd6d80f31e12285ebb7938e340226f7066a52deb4db126b16fc57ec8"}

crate2nix generate

{
  "modelator 0.1.0 (git+https://github.com/informalsystems/modelator?rev=99f656fa8b3cf46a2aa0b6513e4e140d1778c4bd#99f656fa8b3cf46a2aa0b6513e4e140d1778c4bd)": "1j3yqmpv29mi9pmjv9b6f1pj4h7371wvnpi828gg703dpm3d2cl5"
}

JonathanLorimer avatar Jul 17 '21 18:07 JonathanLorimer

it doesn't even follow the revision, the revision is incorrect

auscyber avatar Aug 01 '21 01:08 auscyber

@AusCyberman I'm a bit confused, are you saying that the revision I am using for informalsystems/modelator is incorrect? Unfortunately I am not in control of the upstream Cargo.toml that references the modelator revision. I do believe that the revision is present though https://github.com/informalsystems/modelator/commit/99f656fa8b3cf46a2aa0b6513e4e140d1778c4bd.

If the URL that crate2nix generates is incorrect, then perhaps that is the bug?

JonathanLorimer avatar Aug 06 '21 17:08 JonathanLorimer

@AusCyberman I'm a bit confused, are you saying that the revision I am using for informalsystems/modelator is incorrect? Unfortunately I am not in control of the upstream Cargo.toml that references the modelator revision. I do believe that the revision is present though informalsystems/modelator@99f656f.

If the URL that crate2nix generates is incorrect, then perhaps that is the bug?

Oh, i mean im having a similar problem, and thats its even worse than your describing

auscyber avatar Aug 07 '21 08:08 auscyber

I am working on a PR that would fix this issue (+other issue preventing compiling Veloren with this. I think it isn’t the first issue mentionning Veloren btw).

The issue that prevented me to using it is 1. an issue with making sure each git repo is only overriden a single time (when there are no reason for it to be overrided twice, resulting in duplicated key and thus error) and the vendered library given as input to the crate2nix binary being the whole workspace instead of just the subdirectory containing the crate as expected by Cargo.

I still have to find a good way to find the package folder (currenctly using hardcoded to check if it worked), but it shouldn’t be too hard to implement that somehow (maybe in a subcommand of crate2nix?). I just need to check the name of all crates referenced in the workspace to see if they match the one being vendored.

marius851000 avatar Aug 18 '22 10:08 marius851000

I’m dumb enougth that I forgot I already implemented this. https://github.com/kolloch/crate2nix/pull/166/files

marius851000 avatar Aug 18 '22 10:08 marius851000