A surprisingly common error users make when installing Brew
github.com
github.com
This isn't right. You should be running both commands in your shell. That's what the brew instructions are saying, albeit in a confusing manner.
The first command makes future shells have brew in their $PATH, the second command applies it for the current shell.
To make things even easier for users, brew could forgo the second command and just ask users to close the current terminal and open a new one. This has the added benefit of confirming the first command.
If the issue had occurred, you wouldn't need to run the eval command again, it would have already been run 1,000 times from your .zprofile. Hence I suggest just to delete all references of it then add back one.
But I do take your point that my post could also have been seen as ambiguous and hence added in your suggested changes.
I'm definitely one of those people. The startup script is my personal configuration, under source control and managed to set up an environment exactly how I want it. The very first thing I do on a new computer is clone that repo, so that I have my standard working environment available. It's definitely not a dumping ground for anything that has just been installed.
> I agree that it would be pretty easy for the installer to check and add the lines if they are missing.
But this is where it gets difficult, because that's in no way an easy thing to check. My .bashrc sources a .bashrc_local, so that I can have some computer-specific settings. It has conditionals, based on what tools are available on the current machine. Heck, some of the commands are generated by a python script, such as coloring the PS1 pseudorandomly based on the hostname, so I can tell at a glance which computer I'm ssh'ed into.
(Side note, I definitely need to clean it out at some point, as it has definitely accumulated a lot of cruft over the years.)
Determining if a particular script is sourced requires solving the halting problem. Granted, doing a quick grep for the name of the setup script is probably sufficient, but an installer shouldn't be editing my setup script even if it doesn't find anything.
One counter-argument might be that if the user doesn’t add it themselves, they’re less likely to remember where it is so they can remove it if needed. However, Homebrew already gives you a command to add it that you can blindly copy and paste, which is already not going to stimulate memory very much. I don’t think the script doing it automatically is any worse, as long as it makes sure to explain what it’s doing – that is, display the line it’s adding and the path it’s adding it to.
I will admit though that the PATH stuff was confusing when I was first starting out with programming. But now that I'm a unix nerd, I much prefer to have more control and set things up exactly how I like.
No, installers should not be automatically modifying your profile or your PATH. That would be overstepping significantly, and violating the expectations of most users.
I know mercurial and other packages of type have done this to me
.aliases .exports .paths????
I'm developing on Windows, and here are the tools that took the libery to add themselves to PATH:
- mingw64
- ImageMagick
- Chocolatey
- pdftk
- calibre
- OpenSSH
- Docker
- GnuPG
- VS Code
and also simply lots of runtimes:
- Java
- Python
- Ruby
- .NET Core
Perhaps a better implementation would be a choice:
You need too add `eval "$(/bin/brew shellenv)"` to your dotfiles. Would you like us to do this for you?
1. Yes
2. No I will do this myselfThat makes the (IMO false) assumption that people doing things for themselves by following instructions tend to learn what those things do, rather than simply remembering a "magic" ritual that made something work. Some people will take the time to study and learn how the various commands work and the syntax of different shell & scripting languages. Most won't.
(This is one instance in which I wish the installers, etc, would keep to the tradition.)
Linux distros usually have a mechanism that allows a package to modify a shell's environment without touching dot files that user is used to editing. On Fedora, /etc/profile sources all the .sh files in /etc/profile.d. So for example, installing the "snap" package write a file named /etc/profile.d/snap.sh, which contains this:
# Expand $PATH to include the directory where snappy applications go.
snap_bin_path="/var/lib/snapd/snap/bin"
if [ -n "${PATH##*${snap_bin_path}}" ] && [ -n "${PATH##*${snap_bin_path}:*}" ]; then
export PATH="$PATH:${snap_bin_path}"
fiThis one arguably makes sense though. Because it's being used to install separately from the OS (eg you can use brew on linux to provide a per-user package manager in $HOME), setting "my brew" system-wide might not be the sensible default. (But then, I can't remember the last time I saw a mac that was genuinely multi-user).
I guess there's no one answer, but creating /etc/paths.d/homebrew might belong on the list of options.
I only realised when I finally got fed up with my terminal taking several seconds to start, I dug into why and found that my $PATH had something crazy like >1000 items with the homebrew path taking up pretty much all of them.
I strongly recommend to consider switching to macports or pkgsrc or nix as your package manager. And/or possibly just using a linux VM as your development environment, such as NixOS.
I'm sympathetic to the idea that sometimes software "updates" in fact introduce regressions, but there's a reason that one of the most universal traits among security professionals is "keeping automatic updates enabled".
Surely the appropriate course of action is to fork a project rather than to just run outdated versions?
Forced & default automatic updates have a long-term consequence of reducing fragmentation of the software landscape, ultimately leading to a reduction in the degrees of freedom for the end user.
Developers love this, but on the flip side they're gradually losing personal control over their computers and operating systems and software as a result.
Let's say there's a small piece of software you want to install. A command-line PDF-processing utility, or something. You use brew to install it.
brew decides to update everything. Let's say (not an arbitrary example) this includes OpenSSL. It removes the old OpenSSL.
Everything you built which somehow depends on OpenSSL (and that's a lot of stuff) is now broken. If it was just Homebrew installs, that would be fine, because they'd be upgraded too[1]. But it isn't. It's everything you've built from source which linked against the former, Homebrew-installed OpenSSL.
You now have to spend the rest of the afternoon rebuilding and reinstalling stuff because Homebrew decided to trash a library that it had previously installed... all because you wanted to install one tiny command-line tool.
This has bitten me, and many others, countless times. Here's two examples from a minute's Googling about the OpenSSL issue: https://github.com/kelaberetiv/TagUI/issues/635, https://github.com/kelaberetiv/TagUI/issues/86. But it's far from an isolated case - I've had stuff break on me because brew has decided to upgrade proj, for example, and the newer proj headers aren't backwards-compatible. (Pretty much all open-source geo stuff depends on proj somehow.)
In theory you can brew pin stuff. But either I brew pin everything, or I need a crystal ball to decide what brew will break next. OpenSSL? proj? Postgres? I honestly wouldn't have worked those out for myself.
I am not installing Homebrew on any Mac I own in the future.
[1] In theory. I've had Homebrew make an entire Postgres database unreadable due to an arbitrary, and unwanted, upgrade. Fortunately I was saved by recovering the old data files into Postgres.app, which can run different versions of Postgres.
I've been ruminating on making the switch to nix, you might already be familiar with it, but if not, here's an article I came across:
https://wickedchicken.github.io/post/macos-nix-setup/
Reproducible builds are super appealing: "Nix builds packages in isolation from each other. This ensures that they are reproducible and don't have undeclared dependencies, so if a package works on one machine, it will also work on another."
As is the focus on reliability: "Nix ensures that installing or upgrading one package cannot break other packages. It allows you to roll back to previous versions, and ensures that no package is in an inconsistent state during an upgrade."
From https://nixos.org
- mac-arm-support has just happened in Nix, with comments like "neovim does not work on m1" 2 weeks ago ( https://github.com/NixOS/nixpkgs/issues/95903#issuecomment-8... ). it works just fine in homebrew.
- when installing it on a new mac, you need to use the "--darwin-use-unencrypted-nix-store-volume" switch, which does not inspire confidence (and yes, the documentation points out that on mac computers with T2 chip this still creates an encrypted volume or something, the point is, when installing homebrew i do not have to tell it to do something unencrypted)
- sometimes you get the feeling that nix-on-mac is less important than nixos. like, the whole problem with that "--darwin-use-unencrypted-nix-store-volume" thing is because nix wants to live in the "/nix" directory, and apple does not like that. you could install nix into an another directory and have no apple-problems, but the rest of the nix-ecosystem standardized on "/nix", so if you do that, you get no binary packages etc. with homebrew, you get a package-manager that is focused on macos, it does things the way that makes it easy to use on macos.
still, the advantages of Nix are very impressive, and i'll keep looking at it, i just wanted to balance out all the overly positive switch-to-git articles a little :-)
(NOTE: all this info is from following nix-related topics for a couple months. i did not install nix on mac yet.)
For example, they included their repo github API key in their publicly accessible jenkins site, which meant that anyone could make a commit to the repo, which would be instantly used by anyone going forward:
https://medium.com/@vesirin/how-i-gained-commit-access-to-ho...
Buuuut hands-down the real clown-shoe reason nobody should run brew is that it modifies /usr/local to be user-writeable so they can be exceptionally lazy and install everything as the user.
Guess what's at the top of /etc/paths? /usr/local/bin.
Any script or program you run, anyone who sits down at your computer for less than a minute, can pwn you without any fancy hax0r tricks...just by adding a binary or script with the same name as a command from /usr/sbin/ or /usr/bin. You'd likely never know or notice unless you happened to run 'which', get unexpected behavior from said binary/script, or notice weird shit in ps/Activity Monitor. Imagine a script or binary that pretended to be ssh and politely passed along everything to the real ssh binary while also sending your keys, passphrases, etc to a remote host.
Just ask the user if they want the configuration be automatically applied for them. 99% will say "yes, please" and the rest will be the commenters here who (fairly enough) don't want their init scripts touched by an installer.
I agree the instructions are not clear enough, however. “Run the following two commands, which adds the needful to your profile and current shell” or similar would be a better way to put it.
I'll agree and further add that learning about the shell is essential knowledge building, just as touch typing is an essential skill to have, yet it's surprising how far one can get without.
Learned early on both of these will just make your life easier as a SWE.
> your profile and current shell
What is my profile in this case? What is the current shell? What even is a shell?
A better way would be to ask the user if they want this step to be done for them as part of the installation process. As first-time users will often have to install Brew just to get started on the learning curve of terminal usage.
You're right, it's not a great look for any project to post a criticism of another, largely unrelated project. But where else would they post it?
Posting it like this helps it get the exposure it needs. I think posting it to brew's bugtracker would just get it lost.
We host our answers to common support requests on Github Discussions!
Now, had they submitted a pull request with a clearer instruction, that would truly be the bazaar functioning as intended.
- posted by Fig aficionado.
- in the form of infotainment instead of brew issue ticket.
- points to Fig repo instead of proper issue in brew repository.
Please don't steal or attention on minor thing like this to adv your product.
Jeans is a journalistic term that implies the deliberate placement of hidden advertising or anti-advertising under the guise of author's material.[0]
Advertorial.[1]
Lat I looked the template assumed a very narrow scope of issues you could be reporting and demands an exhaustive amount of information.
Then the instruction becomes an easy 1 step task.
> For brew to be available as command, brew needs to update your path and [bash/zsh/etc] profile. Please select how you wish to continue:
> 1. Please do this for me
> 2. Explain what you're about to do first, then ask me again.
> 3. No thanks. I'll do this myself.
And then you also make sure there's a runtime flag or even env var that can be used to override this, for admins who need to install brew as part of mass deploys.
FWIW, some variation on:
$ exec bash
ought to work, since what you care about is restarting the shell (.bashrc,PATH,etc), rather than the terminal per se.$ source ~/.zshrc
Startup scripts often aren’t idempotent, and it takes work to make sure they are. Please don’t source your startup script unless you know what you’re doing.
I really appreciate the quick test to show whether this problem exists for you.
Like so:
% echo 'stuff' >> ~/.zprofile
If something had to be run as root the prefix was # instead, just like in Bourne Shell.Of course this makes it more difficult to copy and paste, you have to do each line one at a time.
I was taught that you NEVER copy paste anything from the internet into a terminal. You learn what the commands do, and you type them yourself.
Am I just old?
Especially in a situation where you're trying to install something just to get some other thing to work.
The sentiment makes sense locally, but at some point you either need to trust the thing you're working with or you do it yourself.
There's not enough time in a day to "learn the commands yourself" for everything you do, but if you personally choose to learn and type the commands yourself, great!
It's also okay to trust others with what you're doing.
If you run brew, you literally are trusting other's install scripts not to do something malicious. (Seems ironic to run the brew command, but not trust the copy/paste it tells you to do?)
Even if you don't run brew and install/compile the software yourself, you haven't read every line of code that the software is running to know if that's truly safe.
It's not ideal, but you need to trust at some level or you're never going to move forward.
Best practice, IMO, is to open as dumb an editor as you can find and pasting the commands into an editor buffer for inspection before running anything in the shell. And, if you don’t understand what it’s ask you to paste into your shell, don’t do it.
Even if you run with JavaScript off entirely, this at least makes you think before you do anything potentially destructive.
# curl foo.com/install.sh | bash -
Installing Homebrew.
I use MacPorts now, since it gets out of your way. It's up to you when you choose to update its index or your packages, which is much more user friendly in my opinion.
Whatt?? It updates itself(which you can stop by ^c and the installation proceeds without updating) which takes around a minute for me but definitely not all the packages only the dependencies.
Not sure if the parent or me has something wrong in the configuration that our experience is so different.
# dedupe path
set path = ( `echo $path | tr ' ' '\n' | perl -ne 'print $_ unless $s{$_}++;' | tr '\n' ' '` )If you're a CEO of anything, anywhere who ever interacts with Hacker News: do yourself a favor and don't submit anything you have had a hand in. It just feels filthy, and it ruins the integrity of the submissions process. Pieces like this hitting frontpage are the reason I can't trust this site anymore...
...Furthermore, I also remember seeing another Fig-related submission earlier in the month. It feels like I'm the target of a hyper-concentrated ad-campaign.