Nix store optimise changing writability

Recently, I haven’t been able to run nix store optimise, and I can’t find anything on Google for the error that I’m getting. Here is the output:

[fisher@workshop ~]$ nix store optimise
error: changing writability of '/nix/store/l06mggwdl3a5m7766m6cdc0n1yxrhgg9-plugins': Operation not permitted

nix doctor is also failing:

[fisher@workshop ~]$ nix doctor
[PASS] PATH contains only one nix version.
error: not an absolute path: '~/.dotnet'

System information:

  • system: "aarch64-darwin"
  • host os: Darwin 21.6.0, macOS 12.5.1
  • multi-user?: no
  • sandbox: no
  • version: nix-env (Nix) 2.9.1
  • channels(fisher): "nixpkgs-22.05"
  • nixpkgs: /Users/fisher/.nix-defexpr/channels/nixpkgs

According to the wiki you should run nix-store --optimize as root.

Regarding doctor, I’m not sure, can you show us echo $PATH, echo $NIX_PATH and tell us your nix version?

According to the wiki you should run nix-store --optimize as root.

Weird, I don’t remember ever needing to do that. But I tried it, and it fixed the error:

[fisher@workshop ~]$ sudo nix store optimise
warning: the group 'nixbld' specified in 'build-users-group' does not exist
[fisher@workshop ~]$ nix store optimise
[fisher@workshop ~]$

I always get the nixbld warning when I run nix commands as root. I think it’s because I have a single user installation. But anyway, re-running nix store without sudo worked, so I think I’m good now. Thanks!

Here are my paths:

[fisher@workshop ~]$ echo $PATH
[fisher@workshop ~]$ echo $NIX_PATH

Should NIX_PATH be empty?

$NIX_PATH can be empty but then <$name> does not work.