Open Mikilio opened 1 year ago
I can't find any direct reference to this in your config, but probably one of the external flakes that you use, sets boot.loader.grub.extraInstallCommands
and uses rmdir
instead of ${lib.getBin coreutils}/bin/rmdir
?
PS: With a recent enough nix, you can set nix.nixPath = [ "nixpkgs=flake:nixpkgs" ]
to get a working NIX_PATH
for the old tooling
Just to clarify: install-grub.pl
is not to blame here, since it is written in perl, and does not explicitly shell out to rmdir
. Instead the error originates from the shell script that executes install-grub.pl
I think.
Since its all scripts in the store, can you try and check which piece of code exactly fails (starting with which nixos-install
and chasing references)?
First I'd like to apologize for my late response.
I remember trying to track the error and found that install-grub.pl is the only place where it happens.
I will look again when I come back to my deployment script. Back then I worked around the error by using systemd-boot.
When I come back to this error I am not sure if I will be able to reproduce this error because my fedora installation does not exist anymore.
I am having the same problem when following this guide to install nixos on a dedicated server: https://github.com/nix-community/nixos-install-scripts/blob/master/hosters/hetzner-dedicated/hetzner-dedicated-wipe-and-install-nixos.sh
I have modified the script to include pkgs.coreutils
in the installation environment, but it did not help.
Running nixos-install
results in the following:
$ PATH="$PATH" `which nixos-install` --no-root-passwd --root /mnt --max-jobs 40
++ which nixos-install
+ PATH=/root/.nix-profile/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ /root/.nix-profile/bin/nixos-install --no-root-passwd --root /mnt --max-jobs 40
building the configuration in /mnt/etc/nixos/configuration.nix...
/nix/store/c17y1bb883fyxxgjp1v0f3f9sijnh9a9-nixos-system-hetzner-23.05.2209.ac1acba43b2
installing the boot loader...
setting up /etc...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
updating GRUB 2 menu...
installing the GRUB 2 boot loader on /dev/sda...
Installing for i386-pc platform.
Installation finished. No error reported.
installing the GRUB 2 boot loader on /dev/sdb...
Installing for i386-pc platform.
Installation finished. No error reported.
/nix/var/nix/profiles/system/sw/bin/bash: line 10: rmdir: command not found
Edit 1: I tried executing the nixos-install
command with -vvvvvvvvvv
, but there is no more information on this error. If I instead add --keep-going
, it anyways stops after the missing rmdir
command, and e.g. the ssh key of root
is not added correctly.
Edit 2: Tracing the error:
which nixos-install
resolves to /nix/store/ka7qp6wsjzss72x0zrswh7rp42f4rv97-nixos-install/bin/nixos-install
, which in line 199 calls nixos-enter
with a command that includes rmdir
:
NIXOS_INSTALL_BOOTLOADER=1 nixos-enter --root "$mountPoint" -c "$(cat <<'EOF'
# Create a bind mount for each of the mount points inside the target file
# system. This preserves the validity of their absolute paths after changing
# the root with `nixos-enter`.
# Without this the bootloader installation may fail due to options that
# contain paths referenced during evaluation, like initrd.secrets.
# when not root, re-execute the script in an unshared namespace
mount --rbind --mkdir / "$mountPoint"
mount --make-rslave "$mountPoint"
/run/current-system/bin/switch-to-configuration boot
umount -R "$mountPoint" && rmdir "$mountPoint"
which nixos-enter
resolves to /nix/store/y74pw332ib4z5m7acfv7pxvlaw3j111p-nixos-enter/bin/nixos-enter
. In there I am lost though, since I don't find the log message setting up /etc...
in there. However, grepping gave me this:
$ grep -rF 'setting up /etc...' /nix/store
/nix/store/5zc2agvlkh5ckgjfcpfy0amzrrsczfgk-nixos/modules/system/etc/etc.nix: echo "setting up /etc..."
/nix/store/i5g8iw709ky0nmlhqlphcwbvlwjmpg7v-nixpkgs-23.05/nixpkgs/nixos/modules/system/etc/etc.nix: echo "setting up /etc..."
/nix/store/mz5byrgkj4gkwcp0qcixjkwb3ffiqz3y-nixpkgs/nixpkgs/nixos/modules/system/etc/etc.nix: echo "setting up /etc..."
Here I am lost where to continue. I don't know much about nix, but if more information is needed, I am happy to provide it.
@xaverdh @rnhmjoj is there anything more I can provide to help resolve this? I would also be interested in fixing it myself via a pull request, but I would need some guidance, since this would be my first contribution to NixOS.
@xaverdh @rnhmjoj is there anything more I can provide to help resolve this? I would also be interested in fixing it myself via a pull request, but I would need some guidance, since this would be my first contribution to NixOS.
I think a good point to start would be to follow the instructions originally directed at me.
Run the scripts manually (or mark all with set -x) to see which one it actually fails.
A good start already is to have a relatively simple setup to reproduce the error, like you do.
Thanks for the guidance! I have now changed line 209 in /nix/store/ka7qp6wsjzss72x0zrswh7rp42f4rv97-nixos-install/bin/nixos-install
from
umount -R "$mountPoint" && rmdir "$mountPoint"
to
umount -R "$mountPoint" && echo "now doing rmdir in nixos-install" && rmdir "$mountPoint" && echo "rmdir in nixos-install was successful"
Now my log ends with:
now doing rmdir in nixos-install
/nix/var/nix/profiles/system/sw/bin/bash: line 10: rmdir: command not found
So clearly, the offending rmdir
is the one in nixos-install
at line 209.
How do I get coreutils in scope for that one?
You can add
pkgs.coreutils
here
I feel like I remember wanting to do this before and you insisted on using full paths like so /nix/var/nix/profiles/system/sw/bin/rmdir
now I don't know what the reason was back then but maybe this applies here as well?
The script is indeed missing a coreutils dependency. I'm not sure why it would fail on that line, though.
There are references to dirname
, touch
, mkdir
, install
, rm
(all in coreutils) before that line...
It has probably something to do with nixos-enter
.
Adding pkgs.coreutils
at the point propsed by xaverdh seems to do nothing. It still fails while complaining that rmdir does not exist. But I am very confused, because in my fork, the line with the rmdir
contains this: (rmdir "$mountPoint" 2>/dev/null || true)
. Does ||
not apply to a command not being found?
/nix/var/nix/profiles/system/sw/bin/bash: line 10: rmdir: command not found
ah that probably means that we are trying to find rmdir
in that location inside the chroot mount namespace, not in PATH
. So the modifications to PATH
do not propagate there.
The script is indeed missing a coreutils dependency. I'm not sure why it would fail on that line, though. There are references to
dirname
,touch
,mkdir
,install
,rm
(all in coreutils) before that line... It has probably something to do withnixos-enter
.
The $system/sw/bin/bash -c
part is executed in chroot
while the other stuff is not. That is why the other commands don't fail I think
So I can think of two possible solutions:
-c
edit: Both of this will not work, see belowBut why would coreutils not be in the PATH of the chroot?
You are right, it does take the indirection through PATH
, but that points to /run/current-system/sw/bin
. I misinterpreted that part.
Still /run/current-system/sw/bin
will be resolved in the changed root, so will not find the coreutils
of the ambient system.
(I thought the issue was that chroot
clears PATH
, but that is not happening, I just checked)
Maybe it is not that the path is cleared, but rather that the path is not correct anymore in the new root.
Maybe it is not that the path is cleared, but rather that the path is not correct anymore in the new root.
Yes, that is what I meant
I'm also having this issue with the same install script for a hetzner dedi. Was a workaround found for this, as this method of install is broken, and so is nixos-generators kexec-bundle making it very difficult to actually install nixos on hetzner right now.
So coreutils-full
is part of requiredPackages
and should therefore be part of the new system. So I don't quite see why it would fail, since the path should be the same (/run/current-system/sw/bin/rmdir
) as in the ambient system.
Can you check if the install succeeds when you replace rmdir
by /run/current-system/sw/bin/rmdir
?
Yeah, that seems to have worked. Very odd how it's not picking it up from the system we are trying to install from. Thanks for the help, I hope this narrows it down a bit!
Wild guess would be that some form of caching by the shell happens, that makes it look for the resolved path from the ambient system. Anyway if that does happen to fix it, care to open a pr?
So is there a temporary workaround for this at the moment, if anybody was able to bypass the error?
PS: Nvm I sudo edited the script and hardcoded the path /nix/var/nix/profiles/system/sw/bin/rmdir
there in nixos-install:209
. I know not good to sudo edit cryptographically hashed nix path, but anyway, it works till the moment things are installed.
I'm having the same issue with mount
and not rmdir
: there was previously an issue for it there: https://github.com/NixOS/nixpkgs/issues/220211, and it seems I am encountering it again
I tried writing a patch for it (adding an echo "POLIORCETICS: going to call 'mount'
inside the call to nixos-enter
)
overlays = [
(final: super: {
nixos-install-tools = super.nixos-install-tools.overrideAttrs (prev: {
patches = (prev.patches or [ ]) ++ [ ./nixos-install.patch ];
});
})
];
but that didn't pick up the patch
The error I'm getting looks like this:
setting up /etc...
/nix/var/nix/profiles/system/sw/bin/bash: line 7: mount: command not found
/nix/var/nix/profiles/system/sw/bin/bash: line 8: mount: command not found```
I feel like there is not much interest to fix this installation method as for most people it's easier to install using from a bootable installer instead. I don't think this issue will gain that much attention any time soon, and the best thing to do is probably to ensure that this issue is discoverable, that it's installation method is not well-supported, and that the workaround to this gets highlighted.
Instead of trying to fix this, I probably still recommend using a NixOS installer image.
I would welcome any ideas on how to achieve the above.
Was also getting mount: command not found
when trying to nixos-install
from an x86 Arch linux onto an aarch64-linux drive.
Prefixing the mount
commands (in the nixos-enter
call) with /run/current-system/sw/bin/
seems to have worked.
can someone check if adding
hash -r
here before the set -e
works?
(e.g. by locally copying and modifying the script, as was done before by ppl in this thread)
If that does work, I can open a pull request
draft pr is here: https://github.com/NixOS/nixpkgs/pull/355269
You can alternatively try to use the nixos-install
from there
Describe the bug
Following bug occurs in install-grub.pl when executing the following command
Coreutils functions are not in scope (finishes install when executing in
nix develop nixpkgs#coreutils
but result doesn't boot).Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should just finish installation and new disk should be able to boot.
Examples
Output:
Additional context
Installing from Non-NixOS system (Fedora) The exact commit of my config when this bug occured is 4b14be37e623395232eee63504ca42050385135a
Notify maintainers
@xaverdh @rnhmjoj
Metadata