-
-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Open
Labels
0.kind: bugSomething is brokenSomething is broken6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOSIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS
Description
Nixpkgs version
- Stable (25.11)
Describe the bug
When the current working directory is in /etc and you switch to a new configuration that remounts /etc (with etc.overlay), some applications break because getcwd returns an error.
Steps to reproduce
cdsomewhere in/etcnixos-rebuild testto a config that changes/etcso it remountspython -c 'import os; print(os.getcwd())'
For a real application that breaks, try jj.
Expected behaviour
Switching configuration should not break an open directory that is present in both the old and new /etc.
Screenshots
No response
Relevant log output
[nix-shell:/etc/nixos]$ pwd
/etc/nixos
[nix-shell:/etc/nixos]$ echo $PWD
/etc/nixos
[nix-shell:/etc/nixos]$ python -c 'import os; print(os.getcwd())'
/etc/nixos
[nix-shell:/etc/nixos]$ nixos-rebuild test --sudo
building the system configuration...
activating the configuration...
remounting /etc...
Moving mount
Mounting beneath top mount
Attaching mount /run/nixos-etc.kQvjgZCHpo -> /etc
Moving single attached mount
reloading user units for majiirpaktu...
restarting sysinit-reactivation.target
the following new units were started: run-keys.mount, run-nixos\x2detc\x2dmetadata.r6kDbokHLZ.mount, sysinit-reactivation.target, systemd-tmpfiles-resetup.service
Done. The new configuration is /nix/store/xy39zvnc2kzif9q2955fvhzbcx79jny2-nixos-system-server-25.11.20251223.76701a1
[nix-shell:/etc/nixos]$ pwd
/etc/nixos
[nix-shell:/etc/nixos]$ echo $PWD
/etc/nixos
[nix-shell:/etc/nixos]$ python -c 'import os; print(os.getcwd())'
Traceback (most recent call last):
File "<string>", line 1, in <module>
import os; print(os.getcwd())
~~~~~~~~~^^
FileNotFoundError: [Errno 2] No such file or directory
[nix-shell:/etc/nixos]$ cd /etc/nixos
[nix-shell:/etc/nixos]$ python -c 'import os; print(os.getcwd())'
/etc/nixos
[nix-shell:/etc/nixos]$ jj
Error: Could not determine current directory
Hint: Did you update to a commit where the directory doesn't exist or can't be accessed?Additional context
Since we put the config in /etc/nixos by default, it's probably not uncommon that a user would hit this situation.
System metadata
- system:
"x86_64-linux" - host os:
Linux 6.12.63, NixOS, 25.11 (Xantusia), 25.11.20251223.76701a1 - multi-user?:
yes - sandbox:
yes - version:
nix-env (Nix) 2.31.2
Notify maintainers
Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)
I assert that this issue is relevant for Nixpkgs
- I assert that this is a bug and not a support request.
- I assert that this is not a duplicate of an existing issue.
- I assert that I have read the NixOS Code of Conduct and agree to abide by it.
Is this issue important to you?
Add a 👍 reaction to issues you find important.
Metadata
Metadata
Assignees
Labels
0.kind: bugSomething is brokenSomething is broken6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOSIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS