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

Reference to undefined variable in systemd-boot #153362

Open
d4hines opened this issue Jan 3, 2022 · 3 comments
Open

Reference to undefined variable in systemd-boot #153362

d4hines opened this issue Jan 3, 2022 · 3 comments
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: systemd

Comments

@d4hines
Copy link
Contributor

d4hines commented Jan 3, 2022

Describe the bug

I believe there's an error in https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py#L284: profile is referenced but is not in scope. This caused nixos-rebuild switch to fail for me.

Steps To Reproduce

I don't have clear reproduction steps :( however, I can tell you what happened:

I was installing the esy package from the https://github.com/anmonteiro/nix-overlays flake into my NixOS system flake. The nixos-rebuild switch failed because one of the dependency packages failed to build.

Going forward, all calls to nixos-rebuild switch failed with an error coming from the above systemd-boot script. I looked at the script, noticed the missing variable, remounted /nix/store as read/write, removed the reference to the missing variable, and nixos-rebuild switch works again. However, I still print the error caught:

[Errno 2] No such file or directory: '/nix/store/sq4mr090vgprxfh8x3hamhfz1hlwsr3p-pem-0.2.4-doc/kernel'

It seems that this was the root error, which bubbled up and was caught by the error handler linked, only there's a bug in the handler code.

I don't know what caused my initial error - the first package to fail to build was https://gitlab.com/nomadic-labs/lwt-exit and I'm guessing there is either some unexpected non-determinism in the test or something peculiar about my system. I'm not sure how that broke my whole NixOS system, but I'm guessing there was some necessary cleanup that was prevented but the bug I've described.

Expected behavior

The script should keep going as intended. Printing out the generation number (which is in scope) would be a helpful clue from which to track down the error.

Screenshots

N/A

Additional context

My system flake is here https://github.com/d4hines/beth/tree/nixos. Not much has changed between the occurrence of the error and now.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

$ nix-shell -p nix-info --run "nix-info -m"
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «string»:1:25:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (nix-info) ]; } ""
             |           

(Obviously there's a problem with this output. I hypothesize the reason NIX_PATH is missing has something to do with installing NixOS from a flake via the method described in https://nixos.org/manual/nixos/stable/index.html#sec-installing-from-other-distro. This may or may not be related to the initial cause of my error, but regardless, I think I've still found a real bug in the above python systemd-boot script).

@d4hines d4hines added the 0.kind: bug Something is broken label Jan 3, 2022
@d4hines d4hines changed the title Reference to undefined varialbe in systemd-boot Reference to undefined variable in systemd-boot Jan 3, 2022
@tadfisher
Copy link
Contributor

Same thing happened here; somehow, perplexingly, the store path for gvfs ended up in /nix/var/nix/profiles/ as a system link. I don't know if this was the cause, but that occurred after running sudo nixos-rebuild switch while in the /run/current-system/sw/share/gvfs/mounts directory. Possibly, there is a root cause in nixos-rebuild where it detects an incorrect root dir.

In my case, removing the offending profile symlink solved the issue.

@tadfisher
Copy link
Contributor

Ah, this seems to be related: #144811

@tadfisher
Copy link
Contributor

And: #93694

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: systemd
Projects
None yet
Development

No branches or pull requests

3 participants