Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hyperknot

macrumors member
Original poster
Dec 22, 2018
33
6
I'd like to use homebrew bash (5.x) instead of the macOS built-in one (3.3). How can I do it?
1. I run brew install bash
2. I added /opt/homebrew/bin/bash to /etc/shells
3. I run chsh -s /opt/homebrew/bin/bash

Yet, when I open a new terminal this is what it says
echo $BASH && echo $BASH_VERSION
/opt/homebrew/bin/bash
3.2.57(1)-release

If I manually run bash, this is that it says

echo $BASH && echo $BASH_VERSION
/opt/homebrew/bin/bash
5.2.32(1)-release

So somehow the $BASH variable is the same but $BASH_VERSION is the old when using chsh / opening new terminal.
 
I'd like to use homebrew bash (5.x) instead of the macOS built-in one (3.3). How can I do it?
1. I run brew install bash
2. I added /opt/homebrew/bin/bash to /etc/shells
3. I run chsh -s /opt/homebrew/bin/bash

Yet, when I open a new terminal this is what it says
echo $BASH && echo $BASH_VERSION
/opt/homebrew/bin/bash
3.2.57(1)-release

If I manually run bash, this is that it says

echo $BASH && echo $BASH_VERSION
/opt/homebrew/bin/bash
5.2.32(1)-release

So somehow the $BASH variable is the same but $BASH_VERSION is the old when using chsh / opening new terminal.
In the Terminal app, you can set a default shell right there under the general section. I’m not sure but this may override other settings. Try setting the full path to homebrew bash there.
 
Thanks, it turns out Alacritty is doing this weird behaviour, other terminals are working correctly.
 
How can I see what version my bash is?

Edit: I just entered bash and it shows 5.2

Could be I installed it, when I searched for commands to install with homebrew and just installed some without knowing what they are.
 
echo $BASH && echo $BASH_VERSION

Tried that, but wasn't in bash and only got an empty line as output. 🙈



Screen Shot 2024-09-18 at 13.44.33.png

P.S.: I don't even know what bash is but I like having newer versions of everything.
 
Thanks, it turns out Alacritty is doing this weird behaviour, other terminals are working correctly.

I changed Terminal (standard macOS) to bash in the homebrew directory as standard and it's now also only version 3.2.

P.S.: Do you maybe know what vagrant is? It's also in the opt directory together with homebrew.
 
Easily build bash from source:
- download bash-5.2.32.tar.gz (or the current latest) from https://ftp.gnu.org/gnu/bash/
- unarchive bash-5.2.32.tar.gz and open a Terminal window into the bash-5.2.32
- run

Code:
./configure

make

sudo make install

- restart Terminal

which bash should return /usr/local/bin/bash and bash --version should return GNU bash, version 5.2.32(1)-release
 
  • Like
Reactions: Adora
You have to use `chsh -s /opt/homebrew/bin/bash`

Thanks.

But I had to change it in the menu too, that it worked.

Why does it show zsh there?
Screen Shot 2024-09-18 at 15.40.49.png

P.S.: I changed my user name a while ago. Will it forever be xxx in Terminal and Finder?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.