NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.92k stars 1.53k forks source link

Multi-user Darwin installer fails to load org.nixos.nix-daemon #2780

Open what-the-functor opened 5 years ago

what-the-functor commented 5 years ago

---- sudo execution ------------------------------------------------------------ I am executing:

$ sudo ln -sfn /nix/var/nix/profiles/default/Library/LaunchDaemons/org.nixos.nix-daemon.plist /Library/LaunchDaemons/org.nixos.nix-daemon.plist

to set up the nix-daemon as a LaunchDaemon

---- sudo execution ------------------------------------------------------------ I am executing:

$ sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist

to load the LaunchDaemon plist for nix-daemon

/nix/store/87i4fp46jfw9yl8c7i9gx75m5yph7irl-nix-2.2.2/Library/LaunchDaemons/org.nixos.nix-daemon.plist: Service is disabled

---- sudo execution ------------------------------------------------------------ I am executing:

$ sudo launchctl start org.nixos.nix-daemon

to start the nix-daemon

---- oh no! -------------------------------------------------------------------- Jeeze, something went wrong. If you can take all the output and open an issue, we'd love to fix the problem so nobody else has this issue.

:(

We'd love to help if you need it.

If you can, open an issue at https://github.com/nixos/nix/issues

Or feel free to contact the team,

LnL7 commented 5 years ago

Is there some more information in /var/log/nix-daemon.log?

what-the-functor commented 5 years ago

@LnL7

accepted connection from pid <unknown>, user tony
accepted connection from pid <unknown>, user tony
accepted connection from pid <unknown>, user tony
accepted connection from pid <unknown>, user tony
accepted connection from pid <unknown>, user tony
accepted connection from pid <unknown>, user tony
unexpected Nix daemon error: interrupted by the user
accepted connection from pid <unknown>, user tony
accepted connection from pid <unknown>, user tony
accepted connection from pid <unknown>, user tony
accepted connection from pid <unknown>, user tony
accepted connection from pid <unknown>, user tony
what-the-functor commented 5 years ago

@LnL7 , I think the above output of /var/log/nix-daemon.log is from something else. I removed the file, re-ran the install script, and nothing is written to the file.

tw-360vier commented 5 years ago

Same problem here. There isn't even a /var/log/nix-daemon.log file on my machine. I'm on os x 10.13.6 (17G6030).

LnL7 commented 5 years ago

There's a problem before the service even starts if nix-daemon log doesn't exist. Try the following.

sudo launchctl start org.nixos.nix-daemon
sudo log show --last 1m | grep nix-daemon

And if that doesn't give any insight, the output of launchctl print system/org.nixos.nix-daemon might help. I just noticed Service is disabled in the output above, could be unrelated but if that's the problem launchctl enable system/org.nixos.nix-daemon might help.

ldub commented 5 years ago

This is reproducible if you run launchctl disable system/org.nixos.nix-daemon and then remove/re-install nix.

Perhaps the installer should detect the Service is disabled message and exit on the launchctl load step. Or, since launchctl enable is the way to fix it, perhaps the installer should just do that and continue.

dmvianna commented 5 years ago

I had the same issue. Got

 $ sudo log show --last 1m | grep nix-daemon
log: warning: The log archive contains partial or missing metadata
log: cannot use --last when archive metadata is missing

Then I tried

$ sudo log erase --all
Deleted selected logs

et voilà

$ sudo launchctl start org.nixos.nix-daemon
$ sudo log show --last 1m | grep nix-daemon
2019-08-27 11:53:05.644729+1000 0x51490    Default     0x0                  12702  0    sudo:   myUser : TTY=ttys000 ; PWD=/Users/myUser ; USER=root ; COMMAND=/bin/launchctl start org.nixos.nix-daemon

:D

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

yangm97 commented 2 years ago

Adding -w to launchctl load to the installer should prevent this issue. From man:

Overrides the Disabled key and sets it to false or true for the load and unload subcommands respectively. In previous versions, this option would modify the configuration file. Now the state of the Disabled key is stored elsewhere on- disk in a location that may not be directly manipulated by any process other than launchd.

nixos-discourse commented 2 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/anyone-up-for-picking-at-some-nix-onboarding-improvements/13152/8

ahmedelgabri commented 1 year ago

I'm getting the same error now on a MacBook Pro (Retina, 15-inch, Mid 2015) running macOS Monterey 12.6.3

This is an existing installation of nix, not a new one.

When I run sudo log show --last 1m | grep nix-daemon after darwin-rebuild switch --flake .

I get the following, which seems to be wrong? $PWD is inside my dotfiles where I called the command

2023-03-01 22:02:11.262564+0100 0x608e     Default     0x0                  6038   0    sudo:    ahmed : TTY=ttys000 ; PWD=/Users/ahmed/.dotfiles ; USER=root ; COMMAND=/bin/launchctl enable system/org.nixos.nix-daemon
2023-03-01 22:02:11.265427+0100 0x606a     Default     0x0                  1      0    launchd: [system:] Enabling service org.nixos.nix-daemon

I tried to run this from my home directory instead sudo launchctl start system/org.nixos.nix-daemon

And then I get this

2023-03-01 22:06:57.179573+0100 0x7480     Default     0x0                  7327   0    sudo:    ahmed : TTY=ttys000 ; PWD=/Users/ahmed ; USER=root ; COMMAND=/bin/launchctl start system/org.nixos.nix-daemon

But again, doesn't seem to actually work because when I try to list all the services I get this

৸ sudo launchctl list | rg nixos
-   0   org.nixos.activate-system
-   0   org.nixos.nix-gc

Without sudo for use level ones I get this

-   0   org.nixos.gnupg-agent
917 0   org.nixos.syncthing
904 0   org.nixos.ui-mode-notify
-   0   org.nixos.isync

So it doesn't seem to be anywhere, because the file doesn't seem to be there at all.

৸ cat /Library/LaunchDaemons/org.nixos.nix-daemon.plist
cat: /Library/LaunchDaemons/org.nixos.nix-daemon.plist: No such file or directory

So what's the solution here?

sambacha commented 12 months ago

On macOS 12.x (Monterey), Apple has changed the behavior of their syslog daemon - it no longer listens on a domain socket. Therefore, you cannot reliably expect this to work on macOS 10.13 and above.

Apple has unified the system logging and syslog no longer contains the entries we would need, even if it did work as expected. Checkout this tool https://eclecticlight.co/consolation-t2m2-and-log-utilities/  and this blog post https://eclecticlight.co/2020/02/07/how-long-does-your-mac-keep-its-log-for/ for more information.