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

crash with fetchFromGitHub tag #304

Open
gepbird opened this issue Dec 11, 2024 · 2 comments · May be fixed by #312
Open

crash with fetchFromGitHub tag #304

gepbird opened this issue Dec 11, 2024 · 2 comments · May be fixed by #312

Comments

@gepbird
Copy link

gepbird commented Dec 11, 2024

Describe the bug

When using nix-update in an update script, and the src being fetchFromGitHub with a tag attribute rather than rev, the script crashes.

Steps To Reproduce

This is not a minimal reproducible example but based on a PR when I found this issue

Steps to reproduce the behavior:

  1. clone/checkout https://github.com/gepbird/nixpkgs/tree/nix-update-tag-crash-demo
  2. nix-shell maintainers/scripts/update.nix --argstr package ps3-disc-dumper
  3. observe the nix-update crash
logs
nixpkgs ❯ nix-shell maintainers/scripts/update.nix --argstr package ps3-disc-dumper                                                                                                                               
                                                                                                                                                                                                                  
                                                                                                                                                                                                                  
Going to be running update for following packages:                                                                                                                                                                
 - ps3-disc-dumper-4.2.5                                                                                                                                                                                          
                                                                                                                                                                                                                  
Press Enter key to continue...                                                                                                                                                                                    
Running update for:                                                                                                                                                                                               
 - ps3-disc-dumper-4.2.5: UPDATING ...                                                                                                                                                                            
 - ps3-disc-dumper-4.2.5: ERROR                                                                                                                                                                                   
                                                                                                                                                                                                                  
--- SHOWING ERROR LOG FOR ps3-disc-dumper-4.2.5 ----------------------                                   
                                                                                                                                                              
error:                                                                                                   
       … while evaluating attribute 'hash'                                                               
         at «string»:37:3:              
           36|   rev = pkg.src.rev or null;                                                                                                                                                                                                  
           37|   hash = pkg.src.outputHash or null;
             |   ^                                  
           38|   go_modules = pkg.goModules.outputHash or null;                                                                                                                                                                              
                                                                                                         
       … while evaluating the attribute 'src.outputHash'                                                                                                      
         at /home/gep/nixpkgs/pkgs/by-name/ps/ps3-disc-dumper/package.nix:14:3:                                                                                                                                                              
           13|                                                                                           
           14|   src = fetchFromGitHub {          
             |   ^                                                                                                                                                                                                                           
           15|     owner = "13xforever";                                                                                                                      
                                                                                                         
       (stack trace truncated; use '--show-trace' to show the full, detailed trace)                                                                                                                                                          
                                                                                                                                                                                                                  
       error: function 'anonymous lambda' called without required argument 'rev'                                                                                                             
       at /home/gep/nixpkgs/pkgs/build-support/fetchgithub/default.nix:4:1:                                                                                                                                                                  
            3| lib.makeOverridable (                                                                                                                                                                              
            4| { owner, repo, rev, name ? "source"                                                                                                                                                                                           
             | ^                                                                                                                                                                                                                             
            5| , fetchSubmodules ? false, leaveDotGit ? null                                                                                                                                                                                 
Traceback (most recent call last):                                                                                                                                                                                                           
  File "/nix/store/rpp0c5qzlqbv7wgjw6s2ql595svc74fd-nix-update-1.7.0/bin/.nix-update-wrapped", line 9, in <module>                                                                                                                           
    sys.exit(main())                                                                                                                                                                                                                         
             ^^^^^^                                                                                                                                                                                                                          
  File "/nix/store/rpp0c5qzlqbv7wgjw6s2ql595svc74fd-nix-update-1.7.0/lib/python3.12/site-packages/nix_update/__init__.py", line 311, in main                                                                                                 
    package = update(options)                                                                                                                                                                                                                
              ^^^^^^^^^^^^^^^                                                                                                                                                                                                                
  File "/nix/store/rpp0c5qzlqbv7wgjw6s2ql595svc74fd-nix-update-1.7.0/lib/python3.12/site-packages/nix_update/update.py", line 440, in update                                                                                                 
    package = eval_attr(opts)                                                  
              ^^^^^^^^^^^^^^^                                                                                                                                                                                                                                                                                               
  File "/nix/store/rpp0c5qzlqbv7wgjw6s2ql595svc74fd-nix-update-1.7.0/lib/python3.12/site-packages/nix_update/eval.py", line 222, in eval_attr                                                                                                                                                                               
    res = run(cmd)                                                                                                                                                                                                                                                                                                          
          ^^^^^^^^                                                                                                                                                                                                                                                                                                          
  File "/nix/store/rpp0c5qzlqbv7wgjw6s2ql595svc74fd-nix-update-1.7.0/lib/python3.12/site-packages/nix_update/utils.py", line 37, in run                                                                                                                                                                                     
    return subprocess.run(                                                                                                                                                                                                                                                                                                  
           ^^^^^^^^^^^^^^^                                                                                                                                                                                                                                                                                                  
  File "/nix/store/zv1kaq7f1q20x62kbjv6pfjygw5jmwl6-python3-3.12.7/lib/python3.12/subprocess.py", line 571, in run                                                                                                                                                                                                          
    raise CalledProcessError(retcode, process.args,                            
subprocess.CalledProcessError: Command '['nix', 'eval', '--json', '--impure', '--expr', '\nlet\n  \n  pkgs = import "/home/gep/nixpkgs";\n  args =  builtins.functionArgs pkgs;\n  inputs = (if args ? system then { system = builtins.currentSystem; } else {}) //\n           (if args ? overlays then { overlays = [ ]; } else {});\n  pkg = (pkgs inputs)."ps3-disc-dumper";\n  sanitiz
ePosition = x: x;\n\n  positionFromMeta = pkg: let\n    parts = builtins.match "(.*):([0-9]+)" pkg.meta.position;\n  in {\n    file = builtins.elemAt parts 0;\n    line = builtins.fromJSON (builtins.elemAt parts 1);\n  };\n\n  raw_version_position = sanitizePosition (builtins.unsafeGetAttrPos "version" pkg);\n\n  position = if pkg ? isRubyGem then\n    raw_version_position\n  
else if pkg ? isPhpExtension then\n    raw_version_position\n  else if (builtins.unsafeGetAttrPos "src" pkg) != null then\n    sanitizePosition (builtins.unsafeGetAttrPos "src" pkg)\n  else\n    sanitizePosition (positionFromMeta pkg);\nin {\n  name = pkg.name;\n  old_version = pkg.version or (builtins.parseDrvName pkg.name).version;\n  inherit raw_version_position;\n  filenam
e = position.file;\n  line = position.line;\n  urls = pkg.src.urls or null;\n  url = pkg.src.url or null;\n  rev = pkg.src.rev or null;\n  hash = pkg.src.outputHash or null;\n  go_modules = pkg.goModules.outputHash or null;\n  go_modules_old = pkg.go-modules.outputHash or null;\n  cargo_deps = pkg.cargoDeps.outputHash or null;\n  cargo_vendor_deps = pkg.cargoDeps.vendorStaging
.outputHash or null;\n  raw_cargo_lock =\n    if pkg ? cargoDeps.lockFile then\n      let\n        inherit (pkg.cargoDeps) lockFile;\n        res = builtins.tryEval (sanitizePosition {\n          file = toString lockFile;\n        });\n      in\n      if res.success then res.value.file else false\n    else\n      null;\n  composer_deps = pkg.composerVendor.outputHash or null;\
n  composer_deps_old = pkg.composerRepository.outputHash or null;\n  npm_deps = pkg.npmDeps.outputHash or null;\n  pnpm_deps = pkg.pnpmDeps.outputHash or null;\n  yarn_deps = pkg.offlineCache.outputHash or null;\n  maven_deps = pkg.fetchedMavenDeps.outputHash or null;\n  mix_deps = pkg.mixFodDeps.outputHash or null;\n  tests = builtins.attrNames (pkg.passthru.tests or {});\n  
has_update_script = pkg.passthru.updateScript or null != null;\n  src_homepage = pkg.src.meta.homepage or null;\n  changelog = pkg.meta.changelog or null;\n  maintainers = pkg.meta.maintainers or null;\n}', '--extra-experimental-features', 'flakes nix-command']' returned non-zero exit status 1.


--- SHOWING ERROR LOG FOR ps3-disc-dumper-4.2.5 ----------------------                                                                                                                       
The update script for ps3-disc-dumper-4.2.5 failed with exit code 1    

Additional context

Found in NixOS/nixpkgs#361506 (comment)
This was mentioned in NixOS/nixpkgs#355973 (comment)

@Mic92
Copy link
Owner

Mic92 commented Dec 13, 2024

Pull requests welcome.

@gepbird
Copy link
Author

gepbird commented Dec 23, 2024

  1. clone/checkout https://github.com/gepbird/nixpkgs/tree/nix-update-tag-crash-demo

Turns out I forgot to rebase on top of the merged NixOS/nixpkgs#355973, so there was no way it could've worked 🤦 (but I still remember updating to tag and the package working, but the update script failing, or my memory is bad)

I can't reproduce this issue either on NixOS/nixpkgs@7822cb3 or on master (NixOS/nixpkgs@f234581).
Does anyone know how to reproduce? cc @JohnRTitor @Atemu from the nixpkgs issue

Edit: however when using the --commit flag, the generated message is incorrect: Diff: https://github.com/sharkdp/fd/compare/None...v10.2.0

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.

2 participants