197

I know Catalina uses zsh as the default login shell and interactive shell, but it is very annoying when I open iTerm.app or run command with /bin/bash, it shows verbose message like below:

$ /bin/bash
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

The support document the message links to is https://support.apple.com/kb/HT208050

How can I hide the verbose logging? I do not want to be reminding that the "default interactive shell is now zsh" every time I open Terminal.

5 Answers 5

257

I found the solution on reddit. The solution is also mentioned in the "How to use a different shell without changing the default" section of the Apple support article mentioned in the bash warning: https://support.apple.com/en-us/HT208050/.

Add:

export BASH_SILENCE_DEPRECATION_WARNING=1

to $HOME/.bash_profile, $HOME/.profile or $HOME/.bashrc and restart iTerm. After that, the warning message will be gone.

2
  • 31
    Note that this is also listed in the "For more details" link that's in that very warning ;)
    – scohe001
    Commented Oct 10, 2019 at 12:31
  • 1
    I found that this only works if set in $HOME/.bashrc - it didn't work if set in $HOME/.bash_profile - at least for the root user on MacOS 13.5 (Ventura).
    – Chris Wolf
    Commented Jan 2 at 19:28
69

Apple's /bin/bash is fairly antiquated (currently v3.2.57). I just switch to use the bash shipped by homebrew (currently v5.0.18), which will incidentally also remove that deprecation warning.

Steps:

  1. Install Homebrew if you haven't already.
  2. Install the latest bash shell with Homebrew:
brew update && brew install bash
  1. If you have an Apple Intel computer, change the shell like this:
sudo chsh -s /usr/local/bin/bash $(whoami)

Or if you have Apple Silicon (e.g. M1):

sudo chsh -s /opt/homebrew/bin/bash $(whoami)
3
  • 1
    This answer should be the most popular answer because it's the best one. Nobody should be using the old version of Bash supplied by Apple. Commented Apr 3 at 13:35
  • This actually broke my terminal app :D (iTerm2 on M1)
    – David
    Commented Apr 11 at 22:39
  • v3 works, why bother installing v5 that could wreak havok to the older scripts Commented May 10 at 13:40
18

I found that becoming root, then adding the deprecation suppression in /etc/profile was more reliable. I was already using ZSH and I was getting the warning every time I opened a new console. Terribly annoying. /etc/profile now reads as follows:


    # System-wide .profile for sh(1)
    export BASH_SILENCE_DEPRECATION_WARNING=1
    
    if [ -x /usr/libexec/path_helper ]; then
            eval `/usr/libexec/path_helper -s`
    fi
    
    if [ "${BASH-no}" != "no" ]; then
            [ -r /etc/bashrc ] && . /etc/bashrc
    fi
3
  • 1
    This is a good way to disable the warning for all users on the computer. My choice also!
    – Jay Lieske
    Commented Jun 18, 2021 at 16:27
  • 2
    Note that on macOS 10.15 "Catalina" the /etc/profile file has permissions 444. Change the permissions to 644 as root before editing the file and change back to 444 afterwards if you want. Commented Jun 22, 2021 at 13:28
  • 1
    /etc/profile also applies to Bourne shell, /bin/sh so I recommend setting BASH_SILENCE_DEPRECATION_WARNING in /etc/bashrc instead. You will still get the warning upon becoming root (via sudo -sH) so you should also set this in /var/root/.bashrc.
    – Chris Wolf
    Commented Jan 2 at 19:57
11

I did a bit of digging and found the extra text (I did read the URL given in the message but missed the line for export BASH_SILENCE_DEPRECATION_WARNING=1)

The issue is that the text you see comes from Apple's version of /bin/bash

strings /bin/bash | grep default shows the text.

So to use bash I would add a newer bash from another source and use that in chsh. I would use a different bash anyway as the Apple version is over 10 years old

Looking at Apple's code for macOS 11.3 in shell.c (Apple don't seem to have released it for 11.4 yet)

Apple have added amoungst other additions

#ifdef __APPLE__
  if (interactive_shell && !act_like_sh) {
      char const * const silence_warning = getenv("BASH_SILENCE_DEPRECATION_WARNING");
      if (!silence_warning || *silence_warning != '1') {
          struct stat sbuf;
          if (stat("/bin/zsh", &sbuf) == 0) {
              fprintf(stderr, "\n"
                              "The default interactive shell is now zsh.\n"
                              "To update your account to use zsh, please run `chsh -s /bin/zsh`.\n"
                              "For more details, please visit https://support.apple.com/kb/HT208050.\n");
          }
      }
  }
#endif

So setting BASH_SILENCE_DEPRECATION_WARNING will remove this (but see the comment on bash being an old version so I would not advise this)

4
  • Thanks. I was hunting around /etc/ trying to find where that warning comes from and what parses forBASH_SILENCE_DEPRECATION_WARNING and as you show, that message is hardcoded into MacOS's /bin/bash
    – Dave X
    Commented Jul 28, 2021 at 17:38
  • Another way to avoid the warning baked into/bin/bash is to chsh to any non-self-deprecating shell such as those listed in /etc/shells
    – Dave X
    Commented Jul 28, 2021 at 17:50
  • 1
    @DaveX Yes but then you are not in bash - so a different question - If you want to keep in bash install a new version as in apple.stackexchange.com/a/400546/237
    – mmmmmm
    Commented Jul 28, 2021 at 18:01
  • 1
    Ah, if you install a new bash and list it in /etc/shells then users can switch themselves to the new bash with chsh, if not, the superuser needs to override their shell.
    – Dave X
    Commented Jul 28, 2021 at 20:11
0

If you are using (as the biggest part of us) iTerm as a teminal emulator and since the bash shipped with osx is rather old the best solution (IMHO) is to configure iTerm to use brew bash and leave the default system shell to whatever else configured by the system (unless you have a reason to do otherwise).

The pros are that if accidentally brew get removed the shell stuff related to your account will continue to work.

The cons are that script executed at boot or at login still use the original (old) bash. This can be a problem or a "feature". Surely those who have these types of problems also know how to solve them.

To do so the steps are:

  • install brew
  • install bash using brew
  • configure iTerm to execute brew bash when you open a new window (or tab)

The defaul shell for iTerm can be configured on profiles. For example to change shell for Default profile:

  • Open Preferences (menu iTerm -> Preferences)
  • Select the pane with Profile configurations
  • Select the desired profile
  • Select "General" tab
  • Under "Command" select "Custom Shell" from pop-up
  • Type the path to your shell (/usr/local/bin/bash or /opt/homebrew/bin/bash)
2
  • 1
    Isn't this basically the same as apple.stackexchange.com/a/400546/9058 ?
    – nohillside
    Commented Feb 17, 2023 at 13:35
  • 1
    No, here you just change default shell for iTerm not for the user at system level. The concern is , for example, that if bash installed with brew is removed the user will probably have difficulty using the system.
    – karlacio
    Commented Feb 17, 2023 at 15:53

You must log in to answer this question.

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