nix-update icon indicating copy to clipboard operation
nix-update copied to clipboard

Trying to update to a version that doesn't exist changes package version

Open worldofpeace opened this issue 4 years ago • 1 comments

If I do the following:

 nix-update --version 517748bcac9484df6a1f03c84f77c9a066ed8793 "pantheon.elementary-calculator"

we will get a traceback

curl: (22) The requested URL returned error: 404 Not Found
error: cannot download source from any mirror
builder for '/nix/store/swrqgasi5gr6508qk9hq30r1hk67v48y-source.drv' failed with exit code 1
error: build of '/nix/store/swrqgasi5gr6508qk9hq30r1hk67v48y-source.drv' failed
Traceback (most recent call last):
  File "/nix/store/qjlas1n0sgnqcmy3ij395a334zbj4jw4-nix-update/bin/.nix-update-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/qjlas1n0sgnqcmy3ij395a334zbj4jw4-nix-update/lib/python3.8/site-packages/nix_update/__init__.py", line 142, in main
    package = update(options)
  File "/nix/store/qjlas1n0sgnqcmy3ij395a334zbj4jw4-nix-update/lib/python3.8/site-packages/nix_update/update.py", line 82, in update
    update_src_hash(opts, package.filename, package.hash)
  File "/nix/store/qjlas1n0sgnqcmy3ij395a334zbj4jw4-nix-update/lib/python3.8/site-packages/nix_update/update.py", line 42, in update_src_hash
    target_hash = nix_prefetch([f"(import {opts.import_path} {{}}).{opts.attribute}"])
  File "/nix/store/qjlas1n0sgnqcmy3ij395a334zbj4jw4-nix-update/lib/python3.8/site-packages/nix_update/update.py", line 37, in nix_prefetch
    res = run(["nix-prefetch"] + cmd)
  File "/nix/store/qjlas1n0sgnqcmy3ij395a334zbj4jw4-nix-update/lib/python3.8/site-packages/nix_update/utils.py", line 32, in run
    return subprocess.run(command, cwd=cwd, check=check, text=True, stdout=stdout)
  File "/nix/store/f87w21b91cws0wbsvyfn5vnlyv491czi-python3-3.8.3/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['nix-prefetch', '(import ./. {}).pantheon.elementary-calculator']' returned non-zero exit status 1.

because that archive doesn't exist.

But this has now written to the expression to have the version 517748bcac9484df6a1f03c84f77c9a066ed8793.

I believe this will require more safely modifying files by not modifying them in place until we know we have a success?

worldofpeace avatar Jul 29 '20 15:07 worldofpeace