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

Error while trying to update rust package #71

Open
starcraft66 opened this issue Nov 15, 2021 · 6 comments
Open

Error while trying to update rust package #71

starcraft66 opened this issue Nov 15, 2021 · 6 comments

Comments

@starcraft66
Copy link

starcraft66 commented Nov 15, 2021

I thought I'd give this tool a go to update the version of nix-index in nixpkgs, however I ran into the following error:

❯ nix run nixpkgs\#nix-update nix-index
$ nix eval --json --impure --experimental-features nix-command --expr (
    let
      inputs = (if (builtins.hasAttr "overlays" (builtins.functionArgs (import ./.))) then { overlays = []; } else { });
    in
    with import ./. inputs;
    let
      pkg = nix-index;
      raw_version_position = builtins.unsafeGetAttrPos "version" pkg;

      position = if pkg ? isRubyGem then
        raw_version_position
      else
        builtins.unsafeGetAttrPos "src" pkg;
    in {
      name = pkg.name;
      old_version = (builtins.parseDrvName pkg.name).version;
      inherit raw_version_position;
      filename = position.file;
      line = position.line;
      urls = pkg.src.urls or null;
      url = pkg.src.url or null;
      rev = pkg.src.url.rev or null;
      hash = pkg.src.outputHash or null;
      mod_sha256 = pkg.modSha256 or null;
      vendor_sha256 = pkg.vendorSha256 or null;
      cargo_sha256 = pkg.cargoHash or pkg.cargoSha256 or null;
      tests = builtins.attrNames (pkg.passthru.tests or {});
    })
error: value is null while a set was expected

       at «string»:18:18:

           17|       inherit raw_version_position;
           18|       filename = position.file;
             |                  ^
           19|       line = position.line;
Traceback (most recent call last):
  File "/nix/store/kawbc785116dj3x3a08zk3fc28b2l0x1-nix-update-0.5.0/bin/.nix-update-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/kawbc785116dj3x3a08zk3fc28b2l0x1-nix-update-0.5.0/lib/python3.9/site-packages/nix_update/__init__.py", line 196, in main
    package = update(options)
  File "/nix/store/kawbc785116dj3x3a08zk3fc28b2l0x1-nix-update-0.5.0/lib/python3.9/site-packages/nix_update/update.py", line 140, in update
    package = eval_attr(opts)
  File "/nix/store/kawbc785116dj3x3a08zk3fc28b2l0x1-nix-update-0.5.0/lib/python3.9/site-packages/nix_update/eval.py", line 89, in eval_attr
    res = run(cmd)
  File "/nix/store/kawbc785116dj3x3a08zk3fc28b2l0x1-nix-update-0.5.0/lib/python3.9/site-packages/nix_update/utils.py", line 35, in run
    return subprocess.run(
  File "/nix/store/jkfriidvazhzbm941q8m46397q8amnqs-python3-3.9.6/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['nix', 'eval', '--json', '--impure', '--experimental-features', 'nix-command', '--expr', '(\n    let\n      inputs = (if (builtins.hasAttr "overlays" (builtins.functionArgs (import ./.))) then { overlays = []; } else { });\n    in\n    with import ./. inputs;\n    let\n      pkg = nix-index;\n      raw_version_position = builtins.unsafeGetAttrPos "version" pkg;\n\n      position = if pkg ? isRubyGem then\n        raw_version_position\n      else\n        builtins.unsafeGetAttrPos "src" pkg;\n    in {\n      name = pkg.name;\n      old_version = (builtins.parseDrvName pkg.name).version;\n      inherit raw_version_position;\n      filename = position.file;\n      line = position.line;\n      urls = pkg.src.urls or null;\n      url = pkg.src.url or null;\n      rev = pkg.src.url.rev or null;\n      hash = pkg.src.outputHash or null;\n      mod_sha256 = pkg.modSha256 or null;\n      vendor_sha256 = pkg.vendorSha256 or null;\n      cargo_sha256 = pkg.cargoHash or pkg.cargoSha256 or null;\n      tests = builtins.attrNames (pkg.passthru.tests or {});\n    })']' returned non-zero exit status 1.
@Mic92
Copy link
Owner

Mic92 commented Nov 15, 2021

It does not work on wrapper, which is the case for nix-index:

This works:

 nix run nixpkgs#nix-update nix-index-unwrapped
$ nix eval --json --impure --experimental-features nix-command --expr (
    let
      inputs = (if (builtins.hasAttr "overlays" (builtins.functionArgs (import ./.))) then { overlays = []; } else { });
    in
    with import ./. inputs;
    let
      pkg = nix-index-unwrapped;
      raw_version_position = builtins.unsafeGetAttrPos "version" pkg;

      position = if pkg ? isRubyGem then
        raw_version_position
      else
        builtins.unsafeGetAttrPos "src" pkg;
    in {
      name = pkg.name;
      old_version = (builtins.parseDrvName pkg.name).version;
      inherit raw_version_position;
      filename = position.file;
      line = position.line;
      urls = pkg.src.urls or null;
      url = pkg.src.url or null;
      rev = pkg.src.url.rev or null;
      hash = pkg.src.outputHash or null;
      mod_sha256 = pkg.modSha256 or null;
      vendor_sha256 = pkg.vendorSha256 or null;
      cargo_sha256 = pkg.cargoHash or pkg.cargoSha256 or null;
      tests = builtins.attrNames (pkg.passthru.tests or {});
    })
fetch https://github.com/bennofs/nix-index/releases.atom
Not updating version, already 0.1.2
$ git -C ./. add /home/joerg/git/nixpkgs/pkgs/tools/package-management/nix-index/default.nix
$ git -C ./. diff --staged
No changes detected, skipping remaining steps

There is room for improvement regarding the error message it throws.

@starcraft66
Copy link
Author

Thanks, making the error message more descriptive would definitely be nice, I probably wouldn't have opened this issue if I realized it had to do with wrapping 😅.

@Mic92
Copy link
Owner

Mic92 commented Nov 15, 2021

it's quite hard from nix-update's perspective to figure out if a package is wrapped or not. But we can write in the error message that we could not find version or src for the package.

@SuperSandro2000
Copy link
Collaborator

But we can write in the error message that we could not find version or src for the package.

so to say we make it a hard requirement for those to exist?

@Mic92
Copy link
Owner

Mic92 commented Nov 16, 2021

Yes. This requirement was there already but not very obvious given this bad error message.

@onny
Copy link

onny commented Jul 16, 2022

I'm also getting this issue trying to update the package sonixd

Even if I manually specify the version to replace with --version like this

nix-update --version 0.15.3 --build sonixd

Would be cool if it also works for this package type too

appimageTools.wrapType2 rec {
  pname = "sonixd";
  version = "0.15.3";

  src = fetchurl {
    url = "https://github.com/jeffvli/sonixd/releases/download/v${version}/Sonixd-${version}-linux-x86_64.AppImage";
    sha256 = "sha256-+4L3XAuR7T/z5a58SXre6yUiVi7TvSAs8vPgEC7hcIw=";
  };

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