6

I installed new bash via brew

brew install bash
which bash # /opt/homebrew/bin/bash
chsh -s /opt/homebrew/bin/bash

I have added /opt/homebrew/bin/bash to /etc/shells

$ bash --version
GNU bash, version 5.1.8(1)-release (aarch64-apple-darwin20.4.0)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

however, in the terminal, I'm still staying in bash3.2.

echo ${BASH_VERSION} # still being 3.2.57(1)-release
0

3 Answers 3

5

The solution is as described by @NobodyNada in the comments. But since he hasn't posted this as an answer for a long time, I paste it here:

Terminal -> Preferences -> General -> Shells open with should be set to "Default login shell".

4

What you've done -should- work.

Might want to verify the contents of /etc/shells:

# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/opt/homebrew/bin/bash

and retry changing the shell:

Scot-MBP:~ sfederman$ chsh -s /opt/homebrew/bin/bash
Changing shell for sfederman.
Password for sfederman:
chsh: no changes made

then testing:

Scot-MBP:~ sfederman$ which bash
/opt/homebrew/bin/bash
Scot-MBP:~ sfederman$ echo ${BASH_VERSION}
5.1.8(1)-release
2

This is how I did it on MacBook Pro (Apple M3 Pro) running Sonoma 14.3.1:

  1. Install bash:
    brew install bash
    
  2. Change the shell to Homebrew's bash:
    sudo chsh -s /opt/homebrew/bin/bash "$USER"
    
    As Ant pointed out, I had to use sudo to avoid this error:
    chsh: /opt/homebrew/bin/bash: non-standard shell
    
  3. Create "~/.bash_profile" and add the path to Homebrew:
    eval "$(/opt/homebrew/bin/brew shellenv)"
    
  4. Quit Terminal.app
  5. Reopen Terminal.app and confirm that bash is the latest version:
    echo ${BASH_VERSION}
    

OPTIONAL:

  1. In Terminal.app, go to Settings... > [General]: Shells open with: and click Default login shell.

    This was a default setting on my OS.

FYI:

My /etc/shells doesn't contain the /opt/homebrew/bin/bash path.

However my Terminal.app does use Homebrew's shell:

$ which bash
/opt/homebrew/bin/bash
$ echo ${BASH_VERSION}
5.2.26(1)-release
1
  • 1
    Nice summary. Would recommend to add the shell to /etc/shells though, so it can also be selected in the Advanced Users definition in System Settings.
    – nohillside
    Commented Feb 10 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .