sudo: /run/current-system/sw/bin/sudo must be owned by uid 0 and have the setuid bit set

When I use sudo in PHPStorm’s terminal, I receive the following message:
sudo: /run/current-system/sw/bin/sudo must be owned by uid 0 and have the setuid bit set
However, I don’t encounter this issue in a standard terminal. Although I have configured zsh with alacritty, removing all shell configurations doesn’t resolve the problem. I use system-wide configurations whenever possible, including Home Manager, but I don’t use flakes.

It’s hard to say exactly how without more context, but the ~why is roughly like:

  • for security reasons, Nix won’t permit setuid etc. on anything in the store
  • sudo needs setuid to work, but the package itself in nixpkgs can’t have it
  • if you’re on NixOS, the “right” thing to be doing is using the sudo wrapper (iirc at /run/wrappers/bin/sudo). If you aren’t on NixOS, the right thing is probably your system’s default sudo
4 Likes

Time ago I stumbled on this kind of issue because the /nix/store used was located on a NFS server in a directory owned by user not root so it raised the must be owned by uid 0. So in your case is it uid 0, setuid bit or both issue ?

Could also be that PHPStorm is running in a cgroup that has privilige elevation disabled or such.

1 Like

I believe i was able to trace the error. Before i switched to NixOs i activated SettingsSync, a feature in IntelliJ IDEs. It seem since i unchecked the sync option for System Settings and delete .idea-folder, its no longer a issue. EDIT: After switching projects to another folder and back the issue is back. what the actual crap is going on here?
EDIT2:
<component name="PhpWorkspaceProjectConfiguration" interpreter_name="/run/current-system/sw/bin/php" />
in .idea/workspace.xml is responsible for this behaviour. If i remove this line/setting, than the issue is gone