Skip to content
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

/usr/local/bin is not writeable by nix-homebrew.user after install #3

Open
Cu3PO42 opened this issue Jul 4, 2023 · 2 comments
Open

Comments

@Cu3PO42
Copy link
Contributor

Cu3PO42 commented Jul 4, 2023

I've installed Homebrew on a fresh macOS x64 VM. Installing a formulae immediately fails because /usr/local/bin is not writeable by my user. Indeed, it is owned by root, even though most other files in in /usr/local are owned by myuser:admin. The bin and Homebrew folders, however are owned by root:wheel.

I could fix this by inserting an appropriate chown in the setup script, but I'm not 100% sure if that is just a band-aid without fixing the underlying root cause.

Unfortunately I don't currently have access to an aarch64 Mac to test the behaviour there.

@Cu3PO42
Copy link
Contributor Author

Cu3PO42 commented Jul 4, 2023

I started looking into this, but have not been able to pinpoint the issue. Here's what I know:

  • initialize_prefix fails to set the correct ownership on /usr/local/bin
  • Rerunning initialize_prefix does not fix the issue
  • Executing the relevant sections manually, /usr/local/bin is added to chowns[@].
  • Running the section that executes these modifications, all conditions appear to be met.
  • If I replace all utilities (i.e. chown, chgrp, ...) with echo <utility> the necessary commands to change /usr/local/bin's ownership are printed. Manually running them has the desired effect.

I currently cannot explain the inconsisties I've observed.

@Cu3PO42
Copy link
Contributor Author

Cu3PO42 commented Jul 5, 2023

Thanks for looking into this! Right now I have a serviceable hot fix for this: I added

  system.activationScripts.extraUserActivation.text = lib.mkOrder 1501 (lib.concatStringsSep "\n" (lib.mapAttrsToList (prefix: d: if d.enable then ''
    sudo chown -R ${config.nix-homebrew.user} ${prefix}/bin
    sudo chgrp -R ${config.nix-homebrew.group} ${prefix}/bin
  '' else "") config.nix-homebrew.prefixes));

to my config, which allows the installation to proceed successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant