Software⏱️ 3 min readπŸ“… 2026-06-11

How to Fix: /bin/bash shell (macOS) throwing `-bash: declare: -A: invalid option` error message at shell start

Error resolving bash shell issue on macOS after switching to and back from Fish.

Quick Answer: Try resetting the shell by running `chsh -s /bin/bash` again, or reinstalling bash using Homebrew (`brew install bash`).

The error '-bash: declare: -A: invalid option' occurs when you try to switch between different shells on macOS Catalina. This specific issue arises because of how the shell configuration files are managed on your system.

Switching shells can be frustrating, especially when trying to revert back to a previous shell version without proper steps. In this guide, we will walk through the possible causes and solutions for resolving this error.

⚠️ Common Causes

  • The primary reason for this issue is that you changed your default shell from bash to fish using the `chsh` command, but did not properly revert back to bash afterwards. When you switched shells, Fish's configuration files were added to the `/etc/shells` list, which caused the error.
  • Another possible cause is that you used the wrong commands to switch between the two shells. Using both `echo /usr/local/bin/fish | sudo tee -a /etc/shells` and `chsh -s /usr/local/bin/fish`, or using the reverse steps without properly removing Fish's configuration files, could lead to this issue.

πŸ”§ Proven Troubleshooting Steps

Reverting Shell Changes Using Correct Commands

  1. Step 1: Firstly, remove the incorrect shell configuration files from the `/etc/shells` list by running `sudo rm /usr/local/bin/fish | sudo tee -a /etc/shells`. This will ensure that Fish's configuration is no longer added to the list.
  2. Step 2: Next, run the correct command to switch back to bash using only one of the following commands: `echo /bin/bash | sudo tee -a /etc/shells` or `chsh -s /bin/bash`. Avoid using both commands as this can cause further issues.
  3. Step 3: After switching back to bash, update your account to use the new shell by running `chsh -s /bin/zsh`. This will ensure that your system is properly configured and you can avoid any potential issues with shell compatibility.

Using a Third-Party Tool to Revert Shell Changes

  1. Step 1: Alternatively, you can use the `chfn` command to revert back to bash. First, run `sudo chfn -i /bin/bash`. This will update your shell configuration and ensure that you are using the correct shell.
  2. Step 2: Next, run `sudo chsh -s /bin/bash` to switch back to bash. This will update your system configuration and ensure that you can use bash as your default shell.

πŸ’‘ Conclusion

To resolve the '-bash: declare: -A: invalid option' error, you need to properly revert back to bash after changing shells using the correct commands or a third-party tool. By following these steps, you should be able to resolve this issue and use bash as your default shell on macOS Catalina.

Did this fix your problem?

If not, try searching for specific error codes.

πŸ” Search Error Database

❓ Frequently Asked Questions