local -A invalid option, the outdated bash A option issue

TL/DR; Make sure your bash or shell program is up to date, with something like brew install bash. Especially if you are on a Mac, and have updated the OS recently.

If you see this error: local: -A: invalid option

There are a number of things that may be triggering this. For me, it was an asdf install of an plugin for a new version of Node.js. Or in a nutshell, an issue trying to update my version of node.

When I did some digging into the line of a node install util, I found there was a bash script that as calling something using an -A option in lib/utils.sh: line 35: local: -A: invalid option.

I was curious why -A would not work, and when I issued the command bash --version, from my shell it was a version from 2007! I can’t believe I have gotten away with using a 2007 shell for so long.

The new Mac OS versions use zsh/the Z shell, and one option is to use this. I did not heed Mac’s warning: The default interactive shell is now zsh … See: https://apple.stackexchange.com/questions/371997/suppressing-the-default-interactive-shell-is-now-zsh-message-in-macos-catalina

As I use a lot of bash aliases, I was a bit wary of switching to the z shell, so I just made sure to install an updated version of bash using homebrew. I plan on looking into the Z shell sometime soon and maybe maybe the switch. It appears there are some niceties to zsh vs bash. There are some great resources on making the switch, my favorite being: https://carlosroso.com/the-right-way-to-migrate-your-bash-profile-to-zsh/

Leave a Reply

Your email address will not be published. Required fields are marked *