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

Fails to fetch cargo dependency using a git repo, maybe because of master vs main #257

Open
tv42 opened this issue Jul 20, 2022 · 1 comment

Comments

@tv42
Copy link

tv42 commented Jul 20, 2022

Nushell (https://github.com/nushell/nushell) at commit db9b88089e9f8ac69ce1a2b0e9f3aff2b892bae5 depends on an unreleased library version, and imports it from git:

https://github.com/nushell/nushell/blob/db9b88089e9f8ac69ce1a2b0e9f3aff2b892bae5/Cargo.toml#L55
https://github.com/nushell/nushell/blob/db9b88089e9f8ac69ce1a2b0e9f3aff2b892bae5/Cargo.lock#L3857

Naersk fails to fetch the sources for that:

$ nix build
fetching Git repository 'https://github.com/nushell/reedline.git'fatal: couldn't find remote ref refs/heads/master
error: program 'git' failed with exit code 128
(use '--show-trace' to show detailed location information)

This might be because the repository uses main not master? I would have expected naersk to cope with that by now, though.

Setting gitAllRefs makes the build go further, so I assume that worked around this particular problem. However, the documentation for gitAllRefs says

Whether to fetch all refs while fetching Git dependencies. Useful if the wanted revision isn't in the default branch. Requires Nix 2.4+. Default: false

which does not apply here; the relevant reedline commit (59f7144d721cd573f629048e753f163f2652334f) is in reedline's default branch, as seen at https://github.com/nushell/reedline/commits/main -- the default branch is just named main not master.

nix build --show-trace
fatal: couldn't find remote ref refs/heads/master
error: program 'git' failed with exit code 128

       … while fetching the input 'git+https://github.com/nushell/reedline.git?rev=59f7144d721cd573f629048e753f163f2652334f'

       … while evaluating the attribute 'buildCommand' of the derivation 'git-deps'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/pkgs/stdenv/generic/make-derivation.nix:278:7:

          277|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          278|       name =
             |       ^
          279|         let

       … while evaluating the attribute 'paths' of the derivation 'crates-io'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/pkgs/stdenv/generic/make-derivation.nix:278:7:

          277|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          278|       name =
             |       ^
          279|         let

       … while evaluating 'outputVal'

       at /nix/store/6p8svd0kaprcjl9jxzpwzaz8s7pqrgi1-source/builtins/to-toml.nix:41:15:

           40|
           41|   outputVal = v:
             |               ^
           42|     let

       … from call site

       at /nix/store/6p8svd0kaprcjl9jxzpwzaz8s7pqrgi1-source/builtins/to-toml.nix:39:9:

           38|           "{ ${valsStr} }" else
           39|         outputVal v;
             |         ^
           40|

       … while evaluating 'outputValInner'

       at /nix/store/6p8svd0kaprcjl9jxzpwzaz8s7pqrgi1-source/builtins/to-toml.nix:28:20:

           27|
           28|   outputValInner = v:
             |                    ^
           29|     let

       … from call site

       at /nix/store/6p8svd0kaprcjl9jxzpwzaz8s7pqrgi1-source/builtins/to-toml.nix:69:42:

           68|           vals = mapAttrsToList
           69|             (k': v': "${quoteKey k'} = ${outputValInner v'}") v;
             |                                          ^
           70|           valsStr = concatStringsSep ", " vals;

       … while evaluating anonymous lambda

       at /nix/store/6p8svd0kaprcjl9jxzpwzaz8s7pqrgi1-source/builtins/to-toml.nix:69:18:

           68|           vals = mapAttrsToList
           69|             (k': v': "${quoteKey k'} = ${outputValInner v'}") v;
             |                  ^
           70|           valsStr = concatStringsSep ", " vals;

       … from call site

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/attrsets.nix:356:16:

          355|   mapAttrsToList = f: attrs:
          356|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
          357|

       … while evaluating anonymous lambda

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/attrsets.nix:356:10:

          355|   mapAttrsToList = f: attrs:
          356|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
          357|

       … from call site

       … while evaluating anonymous lambda

       at /nix/store/6p8svd0kaprcjl9jxzpwzaz8s7pqrgi1-source/builtins/to-toml.nix:133:10:

          132|       concatMapStringsSep "\n"
          133|         (kv: concatStringsSep "\n" (outputKeyVal kv.k kv.v))
             |          ^
          134|         (

       … from call site

       … while evaluating 'concatMapStringsSep'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/lib/strings.nix:111:5:

          110|     # List of input strings
          111|     list: concatStringsSep sep (map f list);
             |     ^
          112|

       … from call site

       at /nix/store/6p8svd0kaprcjl9jxzpwzaz8s7pqrgi1-source/builtins/to-toml.nix:132:7:

          131|     in
          132|       concatMapStringsSep "\n"
             |       ^
          133|         (kv: concatStringsSep "\n" (outputKeyVal kv.k kv.v))

       … while evaluating 'toTOML'

       at /nix/store/6p8svd0kaprcjl9jxzpwzaz8s7pqrgi1-source/builtins/to-toml.nix:119:12:

          118|
          119|   toTOML = attrs:
             |            ^
          120|     assert (typeOf attrs == "set");

       … from call site

       at /nix/store/6p8svd0kaprcjl9jxzpwzaz8s7pqrgi1-source/build.nix:198:19:

          197|     # and git dependencies.
          198|     cargoconfig = builtinz.toTOML {
             |                   ^
          199|       source = {

       … while evaluating the attribute 'cargoconfig' of the derivation 'nu-deps-0.65.1'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/pkgs/stdenv/generic/make-derivation.nix:278:7:

          277|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          278|       name =
             |       ^
          279|         let

       … while evaluating the attribute 'builtDependencies' of the derivation 'nu-0.65.1'

       at /nix/store/d0xl1nq63szk40j5s70qwp3p0zgx4nqb-source/pkgs/stdenv/generic/make-derivation.nix:278:7:

          277|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          278|       name =
             |       ^
          279|         let
reproducing flake.nix
{
  inputs = {
    nixpkgs.url = github:nixos/nixpkgs/nixos-22.05;
    flake-utils.url = github:numtide/flake-utils;
    naersk = {
      url = github:nix-community/naersk;
      inputs.nixpkgs.follows = "nixpkgs";
    };
    nushell = {
      url = github:nushell/nushell;
      flake = false;
    };
  };

  outputs = { self, nixpkgs, flake-utils, naersk, nushell, ... }@inputs:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
        };
        naersk-lib = naersk.lib.${system};
      in
      rec {
        packages.default = naersk-lib.buildPackage {
          pname = "nushell";
          src = nushell;
          buildInputs = with pkgs; [
	    pkg-config
	    openssl
          ];
        };
      });
}
reproducing flake.lock
{
  "nodes": {
    "flake-utils": {
      "locked": {
        "lastModified": 1656928814,
        "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "naersk": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1655042882,
        "narHash": "sha256-9BX8Fuez5YJlN7cdPO63InoyBy7dm3VlJkkmTt6fS1A=",
        "owner": "nix-community",
        "repo": "naersk",
        "rev": "cddffb5aa211f50c4b8750adbec0bbbdfb26bb9f",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "naersk",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1658237535,
        "narHash": "sha256-z3Ff9oSXEPSZMfXdM+r29oJxtyKUnlUOc18U9E6Q48g=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "e732e1fdbf79bec59f7ade4a3675b091b4a9f6d6",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-22.05",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nushell": {
      "flake": false,
      "locked": {
        "lastModified": 1658329773,
        "narHash": "sha256-Y38RK3Taky6/tMG7akOl3OJkxTvzZB9SKH9Vb8pxIuI=",
        "owner": "nushell",
        "repo": "nushell",
        "rev": "db9b88089e9f8ac69ce1a2b0e9f3aff2b892bae5",
        "type": "github"
      },
      "original": {
        "owner": "nushell",
        "repo": "nushell",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "flake-utils": "flake-utils",
        "naersk": "naersk",
        "nixpkgs": "nixpkgs",
        "nushell": "nushell"
      }
    }
  },
  "root": "root",
  "version": 7
}
@tv42
Copy link
Author

tv42 commented Jul 25, 2022

For anyone else who stumbled here by wild googling, https://github.com/ipetkov/crane managed to build my problem project without issues.

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

1 participant