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

No rev specified #109

Closed
energizah opened this issue Jun 13, 2020 · 5 comments · Fixed by #137
Closed

No rev specified #109

energizah opened this issue Jun 13, 2020 · 5 comments · Fixed by #137

Comments

@energizah
Copy link

I'm getting an error which I don't understand. As far as I can tell, I have specified revisions for all of the dependencies, but it errors with No 'rev', 'tag' or 'branch' specified.

{
    "naersk": {
        "branch": "master",
        "description": "Build rust crates in Nix. No configuration, no code generation, no IFD. Sandbox friendly.",
        "homepage": "",
        "owner": "nmattia",
        "repo": "naersk",
        "rev": "1dd63230066a93c61ab7a66934eb0aae3f1a3613",
        "sha256": "1xn8m62ypg13jh4zf101qmfa6gy8cl923fgwvk9c33m573h3k154",
        "type": "tarball",
        "url": "https://github.com/nmattia/naersk/archive/1dd63230066a93c61ab7a66934eb0aae3f1a3613.tar.gz",
        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    },
    "niv": {
        "branch": "master",
        "description": "Easy dependency management for Nix projects",
        "homepage": "https://github.com/nmattia/niv",
        "owner": "nmattia",
        "repo": "niv",
        "rev": "f73bf8d584148677b01859677a63191c31911eae",
        "sha256": "0jlmrx633jvqrqlyhlzpvdrnim128gc81q5psz2lpp2af8p8q9qs",
        "type": "tarball",
        "url": "https://github.com/nmattia/niv/archive/f73bf8d584148677b01859677a63191c31911eae.tar.gz",
        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    },
    "nixpkgs": {
        "branch": "nixos-19.09",
        "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
        "homepage": "https://github.com/NixOS/nixpkgs",
        "owner": "NixOS",
        "repo": "nixpkgs-channels",
        "rev": "e10c65cdb35b6a66491e47e5a85f5d456b4f4eea",
        "sha256": "19csb2s3wyav83zcw9dw488zk2fnz6wcxxz8q6hy43dbph86hxwm",
        "type": "tarball",
        "url": "https://github.com/NixOS/nixpkgs-channels/archive/e10c65cdb35b6a66491e47e5a85f5d456b4f4eea.tar.gz",
        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    }
}
{pkgs, fetchFromGitHub }:

let
  name = "vector";
  version = "0.9.2";
  sources = import ./nix/sources.nix;
  naersk = pkgs.callPackage sources.naersk { };

in naersk.buildPackage {
  inherit name version;
  src = fetchFromGitHub {
    owner = "timberio";
    repo = "vector";
    rev = "v${version}";
    sha256 = "050x6blm11b90kl2bdlk4v5f43fy5js1fpsykayyx9a3q9vd60cv";
  };
}
$ nix-build -E '(import <nixpkgs> {}).callPackage ./default.nix {}'  --show-trace
error: while evaluating the attribute 'builtDependencies' of the derivation 'vector-0.9.2' at /nix/store/g76zggan9y6g82wais1zmrwx5d41vpvd-source/build.nix:133:5:
while evaluating the attribute 'cargoconfig' of the derivation 'vector-deps-0.9.2' at /nix/store/g76zggan9y6g82wais1zmrwx5d41vpvd-source/build.nix:133:5:
while evaluating 'toTOML' at /nix/store/g76zggan9y6g82wais1zmrwx5d41vpvd-source/builtins/to-toml.nix:119:12, called from /nix/store/g76zggan9y6g82wais1zmrwx5d41vpvd-source/build.nix:145:19:
while evaluating 'concatMapStringsSep' at /nix/store/2pdw4wsfdg0mrg9d6kj6myyimimvnj4d-nixos-20.09pre226148.0f5ce2fac0c/nixos/lib/strings.nix:88:5, called from /nix/store/g76zggan9y6g82wais1zmrwx5d41vpvd-source/builtins/to-toml.nix:132:7:
while evaluating 'foldl' at /nix/store/2pdw4wsfdg0mrg9d6kj6myyimimvnj4d-nixos-20.09pre226148.0f5ce2fac0c/nixos/lib/lists.nix:80:20, called from /nix/store/g76zggan9y6g82wais1zmrwx5d41vpvd-source/builtins/to-toml.nix:122:14:
while evaluating 'foldl'' at /nix/store/2pdw4wsfdg0mrg9d6kj6myyimimvnj4d-nixos-20.09pre226148.0f5ce2fac0c/nixos/lib/lists.nix:82:16, called from /nix/store/2pdw4wsfdg0mrg9d6kj6myyimimvnj4d-nixos-20.09pre226148.0f5ce2fac0c/nixos/lib/lists.nix:86:8:
while evaluating anonymous function at /nix/store/g76zggan9y6g82wais1zmrwx5d41vpvd-source/builtins/to-toml.nix:124:16, called from /nix/store/2pdw4wsfdg0mrg9d6kj6myyimimvnj4d-nixos-20.09pre226148.0f5ce2fac0c/nixos/lib/lists.nix:85:14:
while evaluating 'tomlTy' at /nix/store/g76zggan9y6g82wais1zmrwx5d41vpvd-source/builtins/to-toml.nix:102:12, called from /nix/store/g76zggan9y6g82wais1zmrwx5d41vpvd-source/builtins/to-toml.nix:126:20:
while evaluating the attribute 'v' at /nix/store/g76zggan9y6g82wais1zmrwx5d41vpvd-source/builtins/to-toml.nix:130:44:
while evaluating the attribute 'source' at /nix/store/g76zggan9y6g82wais1zmrwx5d41vpvd-source/build.nix:146:7:
No 'rev', 'tag' or 'branch' specified
@evanjs
Copy link

evanjs commented Aug 6, 2020

So this seems to happen for git dependencies in Cargo.toml that do not specify a rev or etc in my case.
Output of (lib.traceVal e) @ https://github.com/nmattia/naersk/blob/dcee40445cfe301ced2d1b11290d6a94ff3aadb9/build.nix#L158
trace: { checkout = <CODE>; key = <CODE>; name = "spi_ccp"; url = "<private-git-url>"; }

Dependency from Cargo.toml:
spi_ccp = { git = "<private-git-url>", version = "1.0.0" }

I can confirm that adding branch to the above dep, e.g.:
spi_ccp = { git = "<private-git-url>", version = "1.0.0", branch = "master" }
Seems to get me past the error mentioned in the OP

@nmattia
Copy link
Collaborator

nmattia commented Aug 7, 2020

Sorry for the delay, slowly catching up on notifications after some time out.

Ah, yes, fetchGit won't be happy without a revision! Do you mean that the Cargo.lock does not record one?

@evanjs
Copy link

evanjs commented Aug 7, 2020

Realizing I might have done a bit too much redacting :P

No rev specified in Cargo.toml

# Cargo.toml
# ...
[dependencies.spi_ccp]
git = "ssh://git@<private-git-server>:7999/comm/spi_ccp.git"
version = "1.0.0"
# ...
# Cargo.lock
# ...
[[package]]
name = "spi_ccp"
version = "1.0.0"
source = "git+ssh://git@<private-git-server>:7999/comm/spi_ccp.git#59f363531f91cb8ea239beab078484a4fc3fc070"
dependencies = [
 "serialport",
]
# ...

Rev specified in Cargo.toml

# Cargo.toml
# ...
[dependencies.spi_ccp]
git = "ssh://git@<private-git-server>:7999/comm/spi_ccp.git"
version = "1.0.0"
rev = "59f363531f91cb8ea239beab078484a4fc3fc070"
# ...
# Cargo.lock
# ...
[[package]]
name = "spi_ccp"
version = "1.0.0"
source = "git+ssh://git@<private-git-server>:7999/comm/spi_ccp.git?rev=59f363531f91cb8ea239beab078484a4fc3fc070#59f363531f91cb8ea239beab078484a4fc3fc070"
dependencies = [
 "serialport",
]
# ...

Note that the contents of Cargo.lock seem to be unchanged... except the rev is specified twice
It is, however, initially given as a parameter (?rev=...) and again after a #
This still seems to get resolved properly, though.

It's almost as if naersk is failing due to not finding certain keys in Cargo.toml, rather than Cargo.lock

@nmattia
Copy link
Collaborator

nmattia commented Aug 10, 2020

Ok, had a proper look at this!

First of all, I didn't realize it was actually naersk throwing the error: https://github.com/nmattia/naersk/blob/648f8c9ccec2a5e56c701895d6ce952b71f0e884/lib.nix#L91-L92

So if the Cargo.toml does not have a rev (or branch or tag) then it throws the error. It looks like a few lines after that we parse the Cargo.lock for a rev (if there is no revision set in the Cargo.toml). So basically, we could first try to parse the Cargo.lock for a rev, and, if one is found, then we simply don't throw the error. It's a matter of moving a few lines up. Is that something that you think would be useful for you?

@evanjs
Copy link

evanjs commented Aug 10, 2020

I do think that such a change, in allowing us to rely on the rev inferred by Cargo.lock, would solve this issue and improve the UX of naersk.

Not sure if not providing a rev or etc in Cargo.toml would impact determinism, but I'm assuming this is fine, as that's what Cargo.lock is for.

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