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 updating go package #144

Closed
arjan-s opened this issue Mar 23, 2023 · 5 comments
Closed

Error while updating go package #144

arjan-s opened this issue Mar 23, 2023 · 5 comments

Comments

@arjan-s
Copy link

arjan-s commented Mar 23, 2023

I'm the maintainer of ntfy-sh and have been using nix-update to help with that. But recently I started getting the error below, and I can't figure out whether it's caused by something that's changed in upstream ntfy.sh or something in nix-update. Or maybe the ntfy-sh package does something wrong?
The upstream release notes don't mention anything about changes to the build method.

nix run nixpkgs#nix-update ntfy-sh
$ nix eval --json --impure --expr 
let
  
  pkgs = import /home/arjan/git/nixpkgs;
  args =  builtins.functionArgs pkgs;
  inputs = (if args ? system then { system = builtins.currentSystem; } else {}) //
           (if args ? overlays then { overlays = [ ]; } else {});
  pkg = (pkgs inputs).ntfy-sh;
  sanitizePosition = x: x;

  raw_version_position = sanitizePosition (builtins.unsafeGetAttrPos "version" pkg);

  position = if pkg ? isRubyGem then
    raw_version_position
  else if pkg ? isPhpExtension then
    raw_version_position
   else
    sanitizePosition (builtins.unsafeGetAttrPos "src" pkg);
in {
  name = pkg.name;
  old_version = pkg.version or (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.rev or null;
  hash = pkg.src.outputHash or null;
  vendor_hash = pkg.vendorHash or null;
  vendor_sha256 = pkg.vendorSha256 or null;
  cargo_deps = pkg.cargoDeps.outputHash or null;
  npm_deps = pkg.npmDeps.outputHash or null;
  tests = builtins.attrNames (pkg.passthru.tests or {});
  has_update_script = pkg.passthru.updateScript or null != null;
  src_homepage = pkg.src.meta.homepage or null;
  changelog = pkg.meta.changelog or null;
} --extra-experimental-features flakes nix-command
fetch https://github.com/binwiederhier/ntfy/releases.atom
Update 2.1.2 -> 2.2.0 in /home/arjan/git/nixpkgs/pkgs/tools/misc/ntfy-sh/default.nix
$ nix-build --expr let src = (import /home/arjan/git/nixpkgs (if (builtins.hasAttr "config" (builtins.functionArgs (import /home/arjan/git/nixpkgs))) then { config.checkMeta = false; overlays = []; } else { })).ntfy-sh.src; in (src.overrideAttrs or (f: src // f src)) (_: { outputHash = ""; outputHashAlgo = "sha256"; }) --extra-experimental-features flakes nix-command
$ nix-build --expr let src = (import /home/arjan/git/nixpkgs (if (builtins.hasAttr "config" (builtins.functionArgs (import /home/arjan/git/nixpkgs))) then { config.checkMeta = false; overlays = []; } else { })).ntfy-sh.go-modules; in (src.overrideAttrs or (f: src // f src)) (_: { outputHash = ""; outputHashAlgo = "sha256"; }) --extra-experimental-features flakes nix-command
Traceback (most recent call last):
  File "/nix/store/zyzyyy1n4sna89dd4fg8z5w6k4bzi1qp-nix-update-0.15.1/bin/.nix-update-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/zyzyyy1n4sna89dd4fg8z5w6k4bzi1qp-nix-update-0.15.1/lib/python3.10/site-packages/nix_update/__init__.py", line 284, in main
    package = update(options)
  File "/nix/store/zyzyyy1n4sna89dd4fg8z5w6k4bzi1qp-nix-update-0.15.1/lib/python3.10/site-packages/nix_update/update.py", line 226, in update
    update_go_modules_hash(opts, package.filename, package.vendor_sha256)
  File "/nix/store/zyzyyy1n4sna89dd4fg8z5w6k4bzi1qp-nix-update-0.15.1/lib/python3.10/site-packages/nix_update/update.py", line 125, in update_go_modules_hash
    target_hash = nix_prefetch(opts, "go-modules")
  File "/nix/store/zyzyyy1n4sna89dd4fg8z5w6k4bzi1qp-nix-update-0.15.1/lib/python3.10/site-packages/nix_update/update.py", line 110, in nix_prefetch
    raise UpdateError(f"empty hash when trying to update {opts.attribute}.{attr}")
nix_update.errors.UpdateError: empty hash when trying to update ntfy-sh.go-modules
@figsoda
Copy link
Collaborator

figsoda commented Mar 23, 2023

Looks like ntfy-sh requires a little more than what nix-update normally does and comes with a update script for that reason, nix-update is able to execute update scripts using the -u flag, so nix-update ntfy-sh -u, or you can do it the vanilla way and run nix-shell maintainers/scripts/update.nix --argstr package ntfy-sh, which nix-update does under the hood with -u

@arjan-s
Copy link
Author

arjan-s commented Mar 23, 2023

Yes, I know, and that part reports another error (which doesn't have to do with nix-update) even though it successfully updates node-packages.nix:

Going to be running update for following packages:
 - ntfy-sh-2.1.2

Press Enter key to continue...

Running update for:
 - ntfy-sh-2.1.2: UPDATING ...
 - ntfy-sh-2.1.2: DONE.

Packages updated!
Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x7f9d42227d90>
Traceback (most recent call last):
  File "/nix/store/0n4y44dnaxafqs7cg625aldrb152x7bx-python3-3.10.10/lib/python3.10/asyncio/base_subprocess.py", line 126, in __del__
    self.close()
  File "/nix/store/0n4y44dnaxafqs7cg625aldrb152x7bx-python3-3.10.10/lib/python3.10/asyncio/base_subprocess.py", line 104, in close
    proto.pipe.close()
  File "/nix/store/0n4y44dnaxafqs7cg625aldrb152x7bx-python3-3.10.10/lib/python3.10/asyncio/unix_events.py", line 547, in close
    self._close(None)
  File "/nix/store/0n4y44dnaxafqs7cg625aldrb152x7bx-python3-3.10.10/lib/python3.10/asyncio/unix_events.py", line 571, in _close
    self._loop.call_soon(self._call_connection_lost, exc)
  File "/nix/store/0n4y44dnaxafqs7cg625aldrb152x7bx-python3-3.10.10/lib/python3.10/asyncio/base_events.py", line 753, in call_soon
    self._check_closed()
  File "/nix/store/0n4y44dnaxafqs7cg625aldrb152x7bx-python3-3.10.10/lib/python3.10/asyncio/base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Anyway, when I run nix-update with -u, it doesn't even try to update the package itself, it only runs the update script for updating the node dependencies. After that, I still have to run nix-update ntfy-sh to update the (go) package as well. And that's where I get the originally reported error.

@figsoda
Copy link
Collaborator

figsoda commented Mar 23, 2023

The error message is a little misleading, basically nix-update failed to find a hash from the error messages because something failed when trying to vendor. You can reproduce the error with nix-build -A ntfy-sh.go-modules.

here is the full log, looks like it's missing mkdocs-simple-hooks
building '/nix/store/b2d7snsg6lnsqnl96d044rxv0792mayx-ntfy-sh-2.2.0-go-modules.drv'...
unpacking sources
unpacking source archive /nix/store/9pf4xqncpkfx4kv5gya642413jqzml62-source
source root is source
patching sources
configuring
building
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
cd web \
        && npm run build \
        && mv build/index.html build/app.html \
        && rm -rf ../server/site \
        && mv build ../server/site \
        && rm \
                ../server/site/config.js \
                ../server/site/asset-manifest.json

> [email protected] build
> react-scripts build

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  313.35 kB  build/static/js/main.9cee74f0.js

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  npm install -g serve
  serve -s build

Find out more about deployment here:

  https://cra.link/deployment

mkdocs build
ERROR    -  Config value 'plugins': The "mkdocs-simple-hooks" plugin is not installed
Aborted with 1 Configuration Errors!
make: *** [Makefile:99: docs-build] Error 1
/nix/store/pw17yc3mwmsci4jygwalj8ppg0drz31v-stdenv-linux/setup: line 136: pop_var_context: head of shell_variables not a function context

I don't know what exactly went wrong, maybe nix-update can print the error log when it fails to find the hash?

it only runs the update script for updating the node dependencies

sounds like a bug with the update script

@arjan-s
Copy link
Author

arjan-s commented Mar 25, 2023

Thank you so much!! I don't think I would have figured out this myself...
This was indeed the problem. I've created a PR for mkdocs-simple-hooks, and with it nix-update ntfy-sh works as expected. I'll take a look at how the update scripts should function too, that wasn't added by me.

@figsoda
Copy link
Collaborator

figsoda commented Mar 26, 2023

opened #145 to improve the error message

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

2 participants