-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Don't read HOME from environment #6622
Conversation
On darwin, sudo does not clear HOME, so HOME will still be set to a user's home directory rather than root's. util::getHome reads that value of HOME and is used in a number of different places, which causes unexpected behavior in quite a few ways See NixOS#1548 for some issues with nix-channel nix profile will symlink ~/.nix-profile to the default system profile nix will create ~/.cache owned by root: $ rm -r ~/.cache $ sudo nix --extra-experimental-features "nix-command flakes" run nixpkgs#hello Hello, world! $ ls -ld ~/.cache drwxr-xr-x 3 root staff 96 Jun 6 17:14 /Users/matthew/.cache I'm guessing similar problems occur elsewhere getHome is used
It is possible to just use |
This will cause Nix to fail if the current user has no password entry, which could happen e.g. in a sandbox or user namespace. So I'm not sure this is a good idea. |
Would these be some better options?
|
Ha, i was just about to start writing a similar patch. Personally i'd vote for option (3), and this was what i was about to implement. |
…ME` second if necessary Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
…ME` second if necessary Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
…ME` second if necessary Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
…ME` second if necessary Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
…ME` second if necessary Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
…ME` second if necessary Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
Closing as #6676 was merged |
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list` will surprisingly return the USER'S channels, rather than `root`'s. Other counterintuitive outcomes can be seen in this PR description: NixOS#6622
On darwin, sudo does not clear HOME, so HOME will still be set to a
user's home directory rather than root's.
util::getHome reads that value of HOME and is used in a number of
different places, which causes unexpected behavior in quite a few ways
See #1548 for some issues with
nix-channel
nix profile will symlink ~/.nix-profile to the default system profile
nix will create ~/.cache owned by root:
$ rm -r ~/.cache
$ sudo nix --extra-experimental-features "nix-command flakes" run nixpkgs#hello
Hello, world!
$ ls -ld ~/.cache
drwxr-xr-x 3 root staff 96 Jun 6 17:14 /Users/matthew/.cache
I'm guessing similar problems occur elsewhere getHome is used