2 min read

macOS Big Sur, Command Line & ZSH

Syed Aslam

I recently upgraded macOS from Catalina to Big Sur. While there are many new features and refined new design and upgraded look and feel, not everything was smoothly ported and broke the command line.

Image

This post notes the fixes for some of the issues I encountered specifically the Command-Line.

Homebrew

First, make sure that the Xcode is installed properly. Xcode is an integrated development environment (IDE) that is comprised of software development tools for macOS. You may have Xcode installed already. To check, in your Terminal window, type:

  $> xcode-select -p

If you receive the following output, then Xcode is installed:

  $> /Library/Developer/CommandLineTools

If you received an error, then in your web browser install Xcode from the App Store and accept the default options.

Once Xcode is installed, return to your Terminal window. Next, you’ll need to install Xcode’s separate Command Line Tools app, which you can do by typing:

  $> xcode-select --install

At this point, Xcode and its Command-Line Tools app are fully installed, and we are ready to check whether Homebrew with:

  $> brew doctor

This threw up a bunch of issues. Most of which was fixed by running the commands suggested by Homebrew itself. However, for one issue I had to uninstall and reinstall Java since it was installed from an older version of the cask file.

  $> ...
  $> Error: Cask 'java' is unreadable: undefined method `undent' for #String:0x00007fd4751f2998 when running brew doctor
  $> ...

I had Gradle and maven installed which depend on Java being installed. So, I had to first uninstall them and then remove Java to reinstall.

  $> brew uninstall --force java
  $> ...
  $> rm -r "$(brew --prefix)/Caskroom/java"
  $> ...
  $> brew install java

After this most of the issues are fixed with Homebrew and my system was ready to brew again. Just to confirm, I ran brew doctor and the Terminal output will read:

  $> Your system is ready to brew.

ZSH

macOS Big Sur changed the default shell to Zsh. This broke my installation of zsh and oh-my-zsh.

  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.

But when I ran chsh -s /bin/zsh no changes were made. Looked like the terminal was not sourcing my ~/.zshrc but from ~/.bash_profile.

I figured the problem could be with my oh-my-zsh installation and tried to uninstall it to fix the problem. But, trying to run uninstall_oh_my_zsh threw command not found:

  $> uninstall_oh_my_zsh
  -bash: uninstall_oh_my_zsh: command not found

I was running bash and it has no idea about any of the oh-my-zsh scripts/functions. To confirm the shell being used, I tried:

  $> echo $0
  /bin/bash

So, the problem was with the oh-my-zsh installation but something else. Since I was using the Terminal.app, the settings were being overridden in its Preferences. Change the shell and set it to open with the default login shell:

Changing this fixed the problems.

Bonus

  1. You should be able to uninstall oh-my-zsh manually with sh ~/.oh-my-zsh/tools/uninstall.sh
  2. For iTerm, change the shell in iTerm > Preferences > Profiles > Login Shell

Image