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

Failure to run the update when using --version-regex and a package without rev in the source #297

Open
liff opened this issue Nov 15, 2024 · 0 comments

Comments

@liff
Copy link

liff commented Nov 15, 2024

It seems that the combination of --version-regex and the absence of rev field in the source causes a failure in the updater.

How to reproduce

Trying to run the updateScript in NixOS/nixpkgs#356109 throws an exception:

Can be reproduced by checking out the PR without the last commit:

nixpkgs$ git remote add liff [email protected]:liff/nixpkgs
nixpkgs$ git checkout remotes/liff/gradle/v8.11^1
nixpkgs$ nix-shell maintainers/scripts/update.nix --argstr path gradle
this derivation will be built:
  /nix/store/q5a0j37yksy0xzbq8i33hq9s7c6zyynl-packages.json.drv
building '/nix/store/q5a0j37yksy0xzbq8i33hq9s7c6zyynl-packages.json.drv'...

Going to be running update for following packages:
 - gradle-8.10.2

Press Enter key to continue...

Running update for:
 - gradle-8.10.2: UPDATING ...
 - gradle-8.10.2: ERROR

--- SHOWING ERROR LOG FOR gradle-8.10.2 ----------------------

Traceback (most recent call last):
  File "/nix/store/w0fw2mvq1636hmnd1hsvfbvhvknzcqrc-nix-update-1.6.0/bin/.nix-update-wrapped", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/nix/store/w0fw2mvq1636hmnd1hsvfbvhvknzcqrc-nix-update-1.6.0/lib/python3.12/site-packages/nix_update/__init__.py", line 311, in main
    package = update(options)
              ^^^^^^^^^^^^^^^
  File "/nix/store/w0fw2mvq1636hmnd1hsvfbvhvknzcqrc-nix-update-1.6.0/lib/python3.12/site-packages/nix_update/update.py", line 456, in update
    update_hash = update_version(
                  ^^^^^^^^^^^^^^^
  File "/nix/store/w0fw2mvq1636hmnd1hsvfbvhvknzcqrc-nix-update-1.6.0/lib/python3.12/site-packages/nix_update/update.py", line 429, in update_version
    return replace_version(package)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/w0fw2mvq1636hmnd1hsvfbvhvknzcqrc-nix-update-1.6.0/lib/python3.12/site-packages/nix_update/update.py", line 41, in replace_version
    line = line.replace(package.rev, package.new_version.rev)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: replace() argument 1 must be str, not None


--- SHOWING ERROR LOG FOR gradle-8.10.2 ----------------------
The update script for gradle-8.10.2 failed with exit code 1

Possible fix

Changing the condition here to:

-                if package.new_version.rev:
+                if package.rev and package.new_version.rev:

fixes the problem in my case, but I’m not 100% sure it’s a proper fix.

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