I accidentally deleted some files from my Applications directory. I don't recall exactly what but some of them included the Cellar directory.

Now, each time I try to open the terminal, it opens the terminal window but it immediately closes (i.e., less than one second). Since, I have no operational terminal, I don't know how to solve the problem of re-installing the terminal or applying any fix. I tried downloading iTerm and installing it but the exact same thing happens to it: the moment I open it, it closes.

Any ideas?

===Update=== Actually tried again, and this was the message that I got. When I click Ok button, the terminal closes immediately. enter image description here

  • Boot into recovery and re-install macOS. Don't wipe the drive. Just re-install over what you have right now. It will fix/replace whatever files were deleted.
    – Allan
    Feb 21, 2018 at 15:08
  • 1
    Isn't there a simple way? Everything else works fine. It's just the terminal I'm missing. I don't want to re-install macOS since I have Linux on my laptop and I don't want to miss it or anything.
    – foobar
    Feb 21, 2018 at 15:12
  • Actually I upgraded to the latest version of macOS and it didn't fix the problem.
    – foobar
    Feb 21, 2018 at 15:13
  • When you reinstall, you're not messing with other partitions. You can even wipe MacOS without interfering with the other ones. In any event, make a backup (use dd to image the drive) then attempt to reinstall.
    – Allan
    Feb 21, 2018 at 15:22
  • 1
    If you launch Terminal.app and a window opens it can't be missing! Cellar is usually related to brew! Your .bash_profile/.bashrc is probably missing something from this folder and obstructs the proper launch of Terminal.app. So either post the content of .bash* or rename it/them to check if it works afterwards.
    – klanomath
    Feb 21, 2018 at 16:37

3 Answers 3


Your default shell is the brew-installed zsh. You probably removed the folder containing zsh and some other important files/folders/libraries.

In the preferences of Terminal (or System Preferences > Users & Groups > ctrl-click user_name > Advanced Options... > login shell | as far as I remember you have to reboot to make this work) set the default shell back to /bin/bash. Then relaunch Terminal and uninstall brew and reinstall it afterwards. You may have to uninstall brew manually by deleting some folders in /usr/local/ if you deleted too many files and folders previously ("I accidentally deleted some files from my Applications directory. I don't recall exactly what but some of them included the Cellar directory.").

In a second step reinstall brew and brew installed execs.


Since you've ruled out a simple reinstall of the OS - it's clearly some environment variable or user setting.

If you have more than one user and ssh enabled, I would try to ssh in from another machine to see if it's your dot files or a system issue.

If you can't do that - I would probably boot to single user mode and remove the /var/db/.AppleSetupDone file and make a new admin account.

That account will let you test if the system shell startup files are compromised or if it's just your user account. From there you can decide to track down each and every file like .bashrc .bash_profile and .profile, etc.. (or if you use zsh - those startup files) and edit / remove / replace them.

Worst case you could make a backup and then clean erase install - and make sure you keep a good account around as you load data from your backup.

It sounds like en environmental setup or some startup file since you've tried the easy thing of reinstalling the system components.


This is because you updated homebrew, but did not update zsh, use the automator to switch csh, and then manually update zsh.

  1. open Finder and search the Automator, then open it.
  2. select application and find 'run shell script' in Utilities, then open it.
  3. switch to '/bin/csh'.
  4. type /usr/local/bin/brew upgrade zsh into the textarea. automator
  • Please edit the question to add details, comments will be deleted sooner or later
    – nohillside
    Jun 18, 2019 at 12:20

You must log in to answer this question.

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