A reminder, please… I think we've talked about it before.
Happy to. Give me a hint of the topic, so I can find it in our past chats.
I know it's a package manager, but is it also installed in /bin?
You mean pnpm. Its global commands go in a folder of its own, not /bin, and if that folder isn't on you get "pnpm's global bin directory is not in PATH". pnpm bin -g says where it is.
I meant Bun.
Then no: Bun isn't in /bin. It installs to ~/.bun/bin/bun, in your home folder, and adds that folder to PATH in ~/.zshrc. which bun says where yours is.
So for pnpm or npm you have to install Node first?
npm comes with Node: install Node and you have it. pnpm doesn't, and it needs Node to run; you usually install it with npm. Bun needs neither.
So if I have Node already?
Then npm is already there, pnpm is one npm install -g pnpm away, and Bun installs beside it with curl -fsSL https://bun.sh/install | bash. They coexist.
Break down for me what that command does.
curl fetches a URL in the terminal. -fsSL are four : fail on an error, no progress bar, but still show errors, and follow redirects. https://bun.sh/install is a shell script on Bun's site. |, the pipe, hands what's on its left to what's on its right, and bash runs it. So: download Bun's install script and run it straight away. It's a common pattern; it means trusting that script with your machine.
Does it install Bun globally?
Yes, for you: ~/.bun/bin/bun, with a line added to ~/.zshrc so you can run bun from any folder. Packages you install with Bun can be global, bun install -g, or local to a project.
Remind me of the difference between tools added to PATH and normal applications like Google Chrome, Figma and so on.
Command-line tools have no window: you type their name, and the finds the file through PATH. Apps like Chrome and Figma live in /Applications and you click them; Finder opens them, and PATH plays no part. Some are both: VS Code can put a code command on PATH, so code . opens the folder you're in.
Why is it called PATH? Why is it in capitals? And you mentioned there's an OS bin and a user bin!
Because it's literally a list of paths, folders separated by colons: /usr/local/bin:/usr/bin:/bin:/Users/you/.bun/bin. The capitals are a Unix habit for an , a setting programs can read, like HOME and USER. And the system's folders, /bin, /usr/bin and /usr/local/bin, need admin rights to change, while folders in your home, like ~/.bun/bin, are yours.
[A screenshot of Bun's installer saying it added ~/.bun/bin to $PATH in ~/.zshrc.]
That's the installer doing it for you: it wrote two lines into ~/.zshrc, one naming Bun's folder and one putting it on PATH. Run source ~/.zshrc and this terminal sees it; new ones will on their own.
What is this ~/.zshrc?
~ is your home folder. The dot hides the file in Finder. zsh is your shell, and rc stands for run commands: it's a script zsh runs every time a new shell starts, holding PATH lines, shortcuts (alias ll="ls -la") and settings. Edit it, then source ~/.zshrc to run it again in the shell you're in.
What's the difference between /bin, /usr/bin and /usr/local/bin?
/bin: the bare minimum, the commands the system needs to boot and survive:ls,cp, the shells./usr/bin: tools that come with the operating system but aren't needed to boot:curl,zip./usr/local/bin: tools added to this machine afterwards:git,node,brew.
- Folder
- /usr/local/bin
- Put there by
- Installers you ran
- Changed by
- Anyone with sudo
- Used by
- Every user
- On PATH
- Yes
- For example
- node, code
So how is /usr/local/bin different from the folders in the user's bin?
Who it's for. /usr/local/bin is for every account on the machine and needs admin rights to write to. ~/.bun/bin or ~/.local/bin is inside your home: only you have it, and no admin rights are needed. On a laptop with one person it hardly shows; on a shared server it matters a lot.
So why the /usr… in /usr/bin and /usr/local/bin?
History. Disks were small in early Unix, so the system was split over two: /bin on the first, the rest on a second, mounted at /usr. Storage grew and the split stayed. /usr/local came later: things particular to this machine, on top of the standard system. That answer said /usr stood for "Unix System Resources".
Aah, I thought it meant user.
Everyone does, and the folder that's really yours is ~, not /usr.
Something else that's confusing is ~/.bun/bin. I thought Bun would be under a bin folder, not the other way round, so ~/bin/.bun.
~/.bun is Bun's own folder: its versions, cache and installs all live there, and bin is the one part of it that holds the command. Delete ~/.bun and Bun is gone, with nothing mixed into a shared folder. Each tool owns its folder and keeps a bin inside.
Why would Bun not install in /usr/local/bin?
No password needed, since it writes only in your home; one folder to delete; room to manage its own versions; and nothing touched that belongs to the machine. Once its folder is on PATH, typing bun works the same either way.
So how come Node is here, in /usr/local/bin… Shouldn't Node be /usr/local/node/bin, then?
Good spot: two habits. Node drops its file into the shared /usr/local/bin; Bun keeps its own folder and puts that on PATH. The answer called it an old convention and a new one, like a guest who spreads their things round the house and one who keeps them in a bag.
- Asks for a password
- Yes. These folders aren't yours
- Gets on PATH
- Nothing to add. /usr/local/bin is on it already
- To take it out
- Five places, by hand, with sudo
Okay, understood! So let's tie all this back to PATH. Where is PATH? When I install a tool, whether it's node in /usr/local/bin or bun in ~/.bun/bin/bun, where does PATH come in?
PATH is a variable in your shell's memory, set as it starts. Type bun and the shell looks in each folder on the list in turn: /usr/local/bin, no; /usr/bin, no; /bin, no; ~/.bun/bin, yes, run it. None of them, and you get command not found.
Looking…
So installing Bun was: the file into ~/.bun/bin, a line into ~/.zshrc; a terminal opens, zsh reads the file and loads PATH; you type bun, and the shell finds it.
So .zshrc is a hidden configuration file for my bash.
Almost: for zsh, not Bash. They're two shells, and each reads its own file, .zshrc and .bashrc. Add a line to .bashrc while you use zsh and it's ignored. echo $SHELL says which you have; Macs have started with zsh since Catalina, in 2019.
And are zsh and bash installed in /usr/local/bin or /usr/bin?
In /bin: /bin/zsh, /bin/bash. The answer's reason was that everything depends on the shell, so it sits with what the system needs to start.
So what runs the tools in /bin, if not the system?
The : the heart of the system, below /bin, which owns the processor, the memory and the disks and makes running programs possible. Press the power button and the firmware starts, then a bootloader, then the kernel, then the shell, which reads ~/.zshrc and sets PATH, and then you can type.
🤯
And it goes further. The bootloader runs the kernel, the firmware runs the bootloader, the firmware is wired into a chip, and the chip runs on electricity. bun install sits on top of all of it.
So, going back to Bun. Since the new convention lets Bun make its own folder, how is Node bundled with it? And if you already had Node installed, does it work with that one, instead of its own bundled Node?
Bun doesn't bundle Node at all. It's a separate , written from scratch in Zig round a different , JavaScriptCore, built to run the same code and packages. So the two sit side by side and never meet: node app.js runs on Node's engine, bun app.js on Bun's.
Ah, okay! So if I have a project running on Bun, it's running its own Node runtime, as opposed to the one I'd installed before.
Its own runtime, yes, though not a Node: the same sheet music, a different musician. Close enough that most code runs on both, not so close that nothing breaks, which is why a project is tested before it switches.
How do I open VS Code from the terminal?
code . opens the folder you're in, if VS Code is on PATH. If not, open VS Code, press Command-Shift-P, and run "Shell Command: Install 'code' command in PATH". It puts /usr/local/bin/code, a link into the app, on PATH.
[A screenshot: zsh: command not found: code.]
That's the case: code isn't on PATH yet. Run the Shell Command from inside VS Code, then try code . again.
What is Homebrew, and where is it installed?
A package manager for macOS: brew install git downloads, installs and later updates it. On Apple's own chips it lives in /opt/homebrew; on Intel Macs it was /usr/local. It keeps each tool's real files in a cellar, a folder per tool per version, and puts a for each in its bin, which is on PATH.
What's the difference between zsh and .zshrc, by the way?
zsh is the program, /bin/zsh, the shell itself. .zshrc is its settings, a text file in your home it reads when it starts. The engine and the seat position.
I didn't understand this part clearly: "/usr/local/bin: tools you manually installed system-wide. This is where tools go when installed by a developer or admin rather than the OS."
A new Mac comes with tools Apple put in /usr/bin, like curl. Then you install your own, brew install node, and those go in /usr/local/bin (or Homebrew's folder): you chose them, they weren't shipped. The furniture that came with the flat, and the furniture you brought.
Why isn't Homebrew installed in /usr/local/bin?
On Intel Macs brew itself is in /usr/local/bin. What it installs goes first into the cellar, /usr/local/Cellar/node/21.0.0/bin/node, with only a link in bin. That's how it keeps several versions and switches between them by moving the link.
And Bun? Just refresh my memory. How does Node come bundled with it? And is it a different Node from the one in /usr/local/bin?
And where is Claude Code installed? I use Claude in the terminal.
With its own installer, the same way as Bun: ~/.local/bin/claude is a link, the files are in ~/.local/share/claude, and your settings in ~/.claude. Installed with npm it would be in npm's global folder; with Homebrew, in Homebrew's. which claude says which you have.