zhaofengli / nix-homebrew

Homebrew installation manager for nix-darwin
MIT License
277 stars 13 forks source link

Extra permissions change needed to install x86-64 brew packages #31

Open ian-h-chamberlain opened 4 months ago

ian-h-chamberlain commented 4 months ago

After activating on a fresh install with enableRosetta = true and trying to install a package under x86_64, I got this error:

$ arch -x86_64 brew install bazelisk 
Error: The following directories are not writable by your user:
/usr/local/bin

You should change the ownership of these directories to your user.
  sudo chown -R ichamberlain /usr/local/bin

And make sure that your user has write permission.
  chmod u+w /usr/local/bin

Looking at the directory it complained about, it seems possible that /usr/local/bin existed prior to homebrew installation due to my organization's device management software:

$ ls /usr/local/bin/
total 0
drwxr-xr-x   4 root  wheel   128B Jul 30 15:12 ./
drwxr-xr-x  16 root  wheel   512B Jul 24 15:07 ../
lrwxr-xr-x@  1 root  wheel    48B Jul 30 15:12 brew@ -> /nix/store/6rc2ik8cfijm7874xwd93ccqzvs7nv0m-brew
lrwxr-xr-x   1 root  wheel    24B Jul 18 15:56 jamf@ -> /usr/local/jamf/bin/jamf

Performing the recommended steps worked and I was able to continue installation, but are my changes likely to get wiped out the next time nix-homebrew is activated? Is this something the activation script would be expected to do itself (i.e. perform those chown/chmod steps on the bin directory if it existed prior to the activation script running)?

Please let me know if there's any extra info I can provide, I can probably try to reproduce by nuking the whole homebrew installation and trying again, maybe also by manually setting permissions back to how they were...


Edit: semi-related question, is there a simple way to declare nix-darwin's homebrew.brews for multiple prefixes at the same time when using nix-homebrew? It seems like it only supports one brewPrefix by default, so I guess I'd need to write my own activation script if I wanted to also install packages under a second prefix with enableRosetta = true?