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

Can't fetch git dependency that is a workspace #207

Open
JonathanLorimer opened this issue Jul 16, 2021 · 9 comments
Open

Can't fetch git dependency that is a workspace #207

JonathanLorimer opened this issue Jul 16, 2021 · 9 comments

Comments

@JonathanLorimer
Copy link

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
Copy link
Author

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
Copy link
Author

JonathanLorimer commented Jul 17, 2021

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 JonathanLorimer changed the title [Question] Can't fetch git dependency that is a workspace? Can't fetch git dependency that is a workspace Jul 20, 2021
@auscyber
Copy link

auscyber commented Aug 1, 2021

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

@JonathanLorimer
Copy link
Author

JonathanLorimer commented Aug 6, 2021

@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?

@auscyber
Copy link

auscyber commented Aug 7, 2021

@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

@marius851000
Copy link
Contributor

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
Copy link
Contributor

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

@ARizzo35
Copy link

I'm still seeing this error when trying to use a git dependency which is a workspace...is this actually fixed? It also seems to only be an issue when using IFD, running crate2nix generate seems to work fine.

++ crate2nix generate -f ./Cargo.toml -o Cargo-generated.nix -h /nix/store/j1iq0mk98vlqsqqlxh5z0msc2yh2zg5n-doomper-crate2nix/crate-hashes.json
Error: while retrieving metadata about ./Cargo.toml: `cargo metadata` exited with an error: error: failed to get `anyhow` as a dependency of package `doomper v0.1.0 (/private/tmp/nix-build-doomper-crate2nix.drv-0/doomper)`

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

Caused by:
  Unable to update registry `crates-io`

Caused by:
  failed to update replaced source registry `crates-io`

Caused by:
  failed to parse manifest at `/nix/store/p7f9nhmf44qpgkrylig6nrami5mgl6da-deps/ib4vp183py1y8zihihx8dyl62lyjjh5m-aravis-0.9.1/Cargo.toml`

Caused by:
  error inheriting `gio` from workspace root manifest's `workspace.dependencies.gio`

Caused by:
  failed to find a workspace root

@ARizzo35
Copy link

ARizzo35 commented Oct 1, 2024

@marius851000 any updates here? Maybe a regression?

apoelstra added a commit to apoelstra/local-nix-ci that referenced this issue Dec 21, 2024
The queuing script was written by ChatGPT and has at least one bug (it
spinloops when it runs out of stuff to do). But it works well enough for
daily work so I'll commit it for now.

This also updates crate2nix/tools.nix, which has many improvements
including upstreaming one of my patches and making another (lockfile
overrides) much simpler to implement.

Also updates nixpkgs. It turns out that cargo 1.77 somehow breaks
crate2nix in the case of git dependencies; there is a maybe-related
bug nix-community/crate2nix#207 ... ok,
so we need to pin rustc in crate2nix. Turns out we can only do this
by editing tools.nix; you can't overlay rustc and cargo anymore; see
this oxalica/rust-overlay#153 which is
basically WONTFIX.

This commit leaves the giant comment in andrew-utils.nix intact, though
it is now outdated (latest supported nixpkgs and crate2nix). As I am
still bisecting to investigate more isssues..
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