7 ms·
I have very mixed feelings about homebrew. When it works, it is awesome, but when it doesn't it can be a serious nightmare. In particular, homebrew refuses to
by lisper 10y ago
I have very mixed feelings about homebrew. When it works, it is awesome, but when it doesn't it can be a serious nightmare. In particular, homebrew refuses to run under sudo. Instead, to instal in /usr/local it wants me to recursively chown /usr/local to myself, which is a Really Bad Idea (tm). I have mostly stopped using it for this reason.
I understand that running a program that runs third-party scripts under sudo is a security nightmare, but there has to be a better solution than globally chowning /usr/local.
[UPDATE] Apparently, this is no longer the case. Good to know!
[UPDATE2] Alas, the problem seems to not have been fully addressed. You still need to chown /usr/local/bin :-(
- mikemcquaid 10y ago> recursively chown /usr/local to myself As of 1.0.0: you don't need to do this any more and we don't ask you to.
- lisper 10y agoAh, that is very good to know! Thank you! I will take a fresh look at homebrew. :-)
- mikemcquaid 10y agoTo perhaps save you some effort: we still ask you to chown e.g. `/usr/local/bin` which may or may not make it unacceptable to you.
- lisper 10y agoThat's not quite as bad as all of /usr/local, but still not great. Why "e.g."? What else is there? And why not just use /usr/local/homebrew or even better, a path determined by an environment variable? I don't mind giving you a user-owned directory to install things in. I mind very much being required to change system default security settings.
- mikemcquaid 10y agoWe don't require you to take ownership of any directories that already exist when macOS is installed (i.e. `/usr/local` subdirectories but not `/usr/local` itself). Regardless of whether we should have picked another path, changing now would require rebuilding all our binary packages and that's a lot of effort with little return and almost certain breakages.
- lisper 10y agoI haven't done a clean install of OS X in a long time, but I'm pretty sure /usr/local/bin exists. But even if it doesn't I don't find this a compelling argument. Having /usr/local/bin owned by root is a universally accepted standard in the unix world, and with very good reason: having /usr/local/bin owned by a user introduces security risks.
- sigzero 10y agoI believe /usr/local/bin is empty on a fresh install.
- ams6110 10y agoIt should be -- after all, it's there for local software.
- hibbelig 10y agoWhat are those risks?
- lisper 10y ago/usr/local/bin is a global resource. It is generally full of binaries that get run by many different users including root. If a regular user can replace those binaries the result is a privilege escalation.
- 10y ago
- the_other 10y ago(Reaching back into foggy memory...) The last time I installed Homebrew, I think I had the problem that `/usr/local/bin` didn't exist, and I didn't have write permissions for `/usr/local/` so I couldn't create it (w/out sudo/chown) etc. This, using Sierra. Does that seem likely? Usual? What's the ideal solution?
- mikemcquaid 10y agoYou need to use `sudo` as a one-off thing when you install Homebrew. Our installer does that for you otherwise we'll prompt you with `brew doctor`.
- jessedhillon 10y agoWhy don't you have your binaries installed in a user-owned directory like ~/brew or whatever, and then put that at the front of the path? Asking people to `chown` a system path is plainly a contravention of the principle of least privilege.
- mikemcquaid 10y ago`~/brew` varies from username to username and requires us to be able to relocate all binaries so they reference the correct path. We do this for as many as possible but it's not possible for all of them.
- andreareina 10y agoI'm on an older version (0.9.5); how do I fix the ownership of my /usr/local tree? EDIT: I know how to `chown`, I mean more, what can I give back to root, what needs to remain under homebrew's control? Does the new version ship with a tool/command that does this?
- mikemcquaid 10y ago`brew update` and check you've not hit the update bug: https://github.com/homebrew/brew#update-bug https://github.com/homebrew/brew#update-bug We'll tell you what permissions you need to keep/remove. Alternatively, uninstall and reinstall Homebrew and similarly we'll tell you on permissions.
- mikepurvis 10y agoIsn't it desirable to run builds as not-root? If you're concerned about safety, you could maybe "freeze" your homebrew install by chowning /usr/local back to root in between brew invocations.
- lisper 10y ago> Isn't it desirable to run builds as not-root? Absolutely. That's why the canonical gnu installation separates "make" from "make install". But homebrew could do the same thing (and maybe it does now -- I need to go back and revisit this because apparently this issue has been resolved.)
- raimue 10y agoVery much the reason why MacPorts requires sudo, so it can drop to a less-privileged "macports" user for builds, without putting your own user account at risk.
- groovy2shoes 10y agoNot to rain on anyone's parade, but I find MacPorts to be superior to Homebrew in every way, from writing the ports themselves, to installing them and managing them. I used to use Homebrew some time ago, but when I got my Mac Mini, I decided to forgo it in favor of MacPorts and Pkgsrc (which Joyent also provides binaries of for OSX). Whatever MacPorts doesn't have (a rare occurrence), Pkgsrc tends to have it. If not, writing a MacPort is incredibly easy with their provided DSL. I was pleasantly surprised that, despite Homebrew taking so much of the OSX package management mind-share these days, MacPorts still has an active and vibrant community going strong. I was also pleasantly surprised by just how well Pkgsrc works on OSX, despite its origins on NetBSD. In fact, Pkgsrc works so well that I've switched to using it on Slackware as my primary package manager for anything not in the base system, preferring it to SlackBuilds.org and sbotools (though I still use sbotools whenever Pkgsrc doesn't have a package I want — which sometimes leads to duplicate dependencies in different paths... still haven't figured out how to avoid that yet...).
- 10y ago
- homebrewster 10y agoThis was a problem for me. I installed Homebrew to my home directory [1] and it works great. I no longer need to chown /usr/local or run any commands under sudo. [1] https://gist.github.com/jaymcgavren/bb85914950578edabad190c3bf670d90 https://gist.github.com/jaymcgavren/bb85914950578edabad190c3...
- Sidnicious 10y agoI do the same (but installed to ~/.homebrew). No issues so far — if anyone knows why this isn't the default, I'd be interested to know.
- wwweston 10y ago> Instead, to instal in /usr/local it wants me to recursively chown /usr/local to myself, which is a Really Bad Idea (tm). Why is this a really bad idea for a personal machine? The only problems I can think of are some subdirectories that are conventionally given some other user ownership to make running a related server under a specific user, and the problem of putting potentially arbitrary probably unreviewed executables in a system-wide path. But the former problem is one you wrestle with anyway if /usr/local is owned by root. And the latter problem... you're going to have some path where you're putting all this stuff, and it's either going to be a personally owned or system owned path. The system-owned choice means giving your package manager sudo and having to run things with sudo (which, without attention, means giving the executables system-wide access). What other problems does a personally owned path create? What's the alternative?
- lisper 10y ago> Why is this a really bad idea for a personal machine? It's a security risk. Having user access to /usr/local allows me (or, more to the point, an attacker running as me and not root) to surreptitiously replace system binaries, some of which may be run by other users. Some of those other users may have access to parts of the system that I don't have. Some of those other users may even be running as root. > What's the alternative? /usr/local/homebrew/bin. Or even better /opt/homebrew/bin. Or even better, a path that is set in an environment variable.
- lucaspiller 10y agoOther than being in a different directory, what difference is that going to make? You are going to have both in your $PATH in order to run the binaries, so if an attacker can write to either bad stuff could happen. Also you can actually install it wherever you like, this is just the default/recommended location: https://github.com/Homebrew/brew/blob/master/docs/Installation.md#untar-anywhere https://github.com/Homebrew/brew/blob/master/docs/Installati...
- stcredzero 10y ago
- SkyMarshal 10y agoI have the same concerns and have been using Nix for my Mac package manager [1] instead. Functionally it's far better, though with far fewer packages available currently. [1]:https://news.ycombinator.com/item?id=11772686 https://news.ycombinator.com/item?id=11772686
- pfranz 10y agoI've been meaning to try out Nix for probably years. I work in vfx and large facilities have particular needs that most packaging systems don't support, but there's a huge about of investment that can be leveraged (dependency resolution, caching). I did a fresh install of macOS with Sierra and decided to use Nix instead of Homebrew this time around. So far I've only started reading through the docs and only have a few things installed; git, vim, tmux. What are your thoughts about using it as a Homebrew alternative? I've been using Homebrew for years and have been a huge fan so far. I often look at formulas when trying to build things from scratch on Linux.
- SkyMarshal 10y agoIf you're considering it for a Homebrew alternative, the main thing is to make a list of all the packages you must have, and then all the ones you would like to have, and then check if they're in Nix. Decide whether you can live with that or not. Besides that, it's great. The about page sums its features up nicely: http://nixos.org/nix/about.html http://nixos.org/nix/about.html
- eltoozero 10y ago>Functionally it's far better For example?
- SkyMarshal 10y agoThe about page sums its features up pretty well, see if there's anything that particularly appeals to you there: http://nixos.org/nix/about.html http://nixos.org/nix/about.html Also the HN link in my previous comment has some good discussion of it, just scroll down past the initial Docker comparison thread. For me the main benefit of it is that I trust it. It doesn't take over system directories like Homebrew, which bugs me even though I'm on a single-user system where that should be ok. Both installs and uninstalls are deterministic, complete, and don't screw anything else up in the system. You can install different versions of the same package side-by-side, which the Debian and Red Hat Alternatives systems also enable, but Nix is more sophisticated about it tagging everything with a cryptographic hash of its build tree. MacPorts and pkgsrc may also provide some of this, but Nix feels more like the git of package managers than anything else I've used, eg the one that finally gets packaging right.
- arvinsim 10y agoI wonder how much of this could have been avoided if they defaulted to a different, user created folder.
- Camillo 10y agoJust install to a different folder. Everything still works.