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.toml: Git Dependencies #149

Closed
a-kenji opened this issue Feb 11, 2021 · 5 comments · Fixed by #157
Closed

Cargo.toml: Git Dependencies #149

a-kenji opened this issue Feb 11, 2021 · 5 comments · Fixed by #157

Comments

@a-kenji
Copy link

a-kenji commented Feb 11, 2021

When I try to build a package with this in the Cargo.toml:

[dependencies]
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "1f1f44f336e5a172361fc1860461bb03667b1ed2", features = ["tls"] }

I get this error message:

fetching Git repository 'https://github.com/SergioBenitez/Rocket.git'fatal: couldn't find remote ref refs/heads/1f1f44f336e5a172361fc1860461bb03667b1ed2
error: --- Error ------------------------------------------------------------------------------------- nix
program 'git' failed with exit code 128
(use '--show-trace' to show detailed location information)

But the rev seems to exist.

If you want I can also attach the --show-trace.

@Mic92
Copy link
Member

Mic92 commented Mar 3, 2021

I have a similiar issue. Those are the commands it tries to execute in this case:

nix-build        29705  16611    0 /scratch/joerg/.nix-profile/bin/nix-build --show-trace
git              30279  29705    0 /nix/store/cdmxpgjyx8nkxyf64rjvpazpi6p5dslb-git-2.30.0/bin/git -C /scratch/joerg/.cache/nix/gitv3/01lpsaj1cwwnf8a3nh0wglq0jpqc1dazg5864mvw47gdf3nvw8vl cat-file -e 5847f1286492b7191f1400e6647fb220f8941f89
git              30280  29705    0 /nix/store/cdmxpgjyx8nkxyf64rjvpazpi6p5dslb-git-2.30.0/bin/git -C /scratch/joerg/.cache/nix/gitv3/01lpsaj1cwwnf8a3nh0wglq0jpqc1dazg5864mvw47gdf3nvw8vl fetch --quiet --force -- https://github.com/rust-vmm/vm-device refs/heads/5847f1286492b
7191f1400e6647fb220f8941f89:refs/heads/5847f1286492b7191f1400e6647fb220f8941f89
git              30281  30280    0 /nix/store/cdmxpgjyx8nkxyf64rjvpazpi6p5dslb-git-2.30.0/libexec/git-core/git remote-https https://github.com/rust-vmm/vm-device https://github.com/rust-vmm/vm-device
git-remote-http  30282  30281    0 /nix/store/cdmxpgjyx8nkxyf64rjvpazpi6p5dslb-git-2.30.0/libexec/git-core/git-remote-https https://github.com/rust-vmm/vm-device https://github.com/rust-vmm/vm-device

The fetch command fails in a reproducible way:

 /nix/store/cdmxpgjyx8nkxyf64rjvpazpi6p5dslb-git-2.30.0/bin/git -C /scratch/joerg/.cache/nix/gitv3/01lpsaj1cwwnf8a3nh0wglq0jpqc1dazg5864mvw47gdf3nvw8vl fetch --quiet --force -- https://github.com/rust-vmm/vm-device refs/heads/5847f1286492b7191f1400e6647fb220f8941f89:refs/heads/5847f1286492b7191f1400e6647fb220f8941f89
fatal: couldn't find remote ref refs/heads/5847f1286492b7191f1400e6647fb220f8941f89

@a-kenji
Copy link
Author

a-kenji commented Mar 3, 2021

Thank you! This fixed the part of:

rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "1f1f44f336e5a172361fc1860461bb03667b1ed2", features = ["tls"] }

But sadly I seem to have a similar Issue with:

ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks", "unstable-exhaustive-types"], rev = "ee814aa84934530d76f5e4b275d739805b49bdef" }

If anyone has a similar issue. I am just patching the Cargo.toml file for now.

Ruma has main as a default branch, and if I specify it in the Cargo.toml everything works.

@Mic92
Copy link
Member

Mic92 commented Mar 3, 2021

Yes. Different default branches are still a problem. The commit that was reverted tried to solve this, but broke the general case.

@jcarrag
Copy link

jcarrag commented Mar 18, 2021

I'm also trying to build a project (conduit) which has a dependency on ruma using naersk.

It's failing for the same main-branch related reason. However, I'm unable to add branch = "main" to conduit's ruma entry in Cargo.toml as the latest commit on main is incompatible.

Do you have any ideas for how to address this?

(Sorry for resurrecting a closed thread and thanks for the awesome lib!)

@a-kenji
Copy link
Author

a-kenji commented Mar 19, 2021

@jcarrag,
I was also trying to build conduit. I changed the Cargo.toml in a very hacky way.
I used the branch of Ruma to point to a different repository that has the rev as the main branch.
I don't know of any other way to remedy this atm, and would also be happy if anyone has a more
elegant solution.

mhuesch added a commit to mhuesch/naersk that referenced this issue Nov 29, 2021
this allows us to avoid issues when the default branch is not named
`master`.

I believe this should fix the issues described in:
nix-community#149
nix-community#140

using this change seems to fix this error I was seeing:
```
fetching Git repository 'https://github.com/sacredcapital/rep_lang.git'fatal: couldn't find remote ref refs/heads/master                                                                            error: program 'git' failed with exit code 128
```
and enables a successful build.

I reproduced the successful build on multiple machines. however I cannot
be full certain that it works in all cases.

additionally, it seems possible that `allRefs = true` causes annoying
extra fetching which might be noticeable for repos with many refs...
mhuesch added a commit to mhuesch/naersk that referenced this issue Jan 11, 2022
this allows us to avoid issues when the default branch is not named
`master`.

I believe this should fix the issues described in:
nix-community#149
nix-community#140

using this change seems to fix this error I was seeing:
```
fetching Git repository 'https://github.com/sacredcapital/rep_lang.git'fatal: couldn't find remote ref refs/heads/master                                                                            error: program 'git' failed with exit code 128
```
and enables a successful build.

I reproduced the successful build on multiple machines. however I cannot
be full certain that it works in all cases.

additionally, it seems possible that `allRefs = true` causes annoying
extra fetching which might be noticeable for repos with many refs...
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

Successfully merging a pull request may close this issue.

3 participants