49

Anyone please help..
How can I fix the following error:

dyld: Library not loaded: /usr/local/lib/libgdbm.4.dylib  
  Referenced from: /usr/local/bin/zsh  
  Reason: image not found  
Prophet
  • 32,350
  • 22
  • 54
  • 79
knz
  • 499
  • 1
  • 4
  • 5
  • 3
    You should probably provide more context as to what you were doing/running, otherwise folks won't be able to help you. – andersonvom Sep 11 '14 at 18:20
  • For me, this was the reason `tmux` was exiting with immediately with `[exited]`. Fixed with `brew upgrade zsh`. – Max Goodridge Nov 12 '18 at 17:39

9 Answers9

121

Simple reinstall zsh will help you:

brew reinstall zsh && brew unlink zsh && brew link zsh

Alternatively you can try to upgrade zsh

brew upgrade zsh
De_Vano
  • 1,404
  • 1
  • 10
  • 5
  • @AdamChubbuck for me it didn't help so I've just reinstalled it. – De_Vano Oct 31 '18 at 19:56
  • For those unable to open unable to even open a terminal window: @coderuby answer + comments https://stackoverflow.com/a/52791702/4010391 – Travis Apr 04 '19 at 00:52
42

Late to the party on this one, but simply running

brew upgrade zsh

solved my issue on MacOS High Sierra. Trying to uninstall gdbm will throw dependency errors against zsh and python, and re-doing the symlinks didn't solve for me, either

C.Nivs
  • 12,353
  • 2
  • 19
  • 44
  • 3
    This worked for me on after update to High Sierra 10.13.6. Thanks! – Architek1 Aug 03 '18 at 20:31
  • Now that you mention it, that's when mine broke as well. I pulled my disk image from a macbook running Sierra onto one with High Sierra and that's when problems arose – C.Nivs Aug 08 '18 at 18:09
  • 1
    Worked for me too. I'd recommend trying this before reinstalling simply because it's faster – Gerard Aug 08 '18 at 23:57
  • after trying quite a few (!) alternate approaches (incl. forced removal of gdbm and reinstallation) this worked perfectly. Thanks. – Michael Aug 28 '18 at 21:01
  • Where do you run the command? I can't open neither iTerm nor Terminal – Gavriel Oct 25 '18 at 20:23
  • @Gavriel I ran it in iTerm2. Usually the dependency should just block your zsh shell from running, not standard bash. What error does your terminal throw? – C.Nivs Oct 27 '18 at 18:20
8

I suspect you are running into problems while working with Homebrew on MacOSX. I am actually saying this because I have just run into the exact same situation.

The problem comes after upgrading my MacOSX version to Maverick from Mountain Lion while having already installed Homebrew (of course this may apply to previous and future upgrades). After the upgrade you will need also:

  • Reinstall the XCode tools
  • Run an update on Homebrew

    brew update

  • Run a general upgrade of your Homebrew packages

    brew upgrade

  • Make sure you do not have any other problems on your installation

    brew doctor

Finally you may find that certain packages are failing due to missing libraries, which seems to be the case you are describing. The idea here is to reinstall the library missing using the brew command.

In your case you would need to reinstall the gdbm library by performing the next steps on your terminal:

brew uninstall gdbm
brew install gdbm

That should fix it.

Sergio
  • 303
  • 1
  • 3
  • 7
8

To be able to fix my terminal/iterm2/hyper (all were broke because of broken zsh) I had to first change my terminal settings 'Shells open with' from a custom command to the default login shell.

enter image description here

Without these changes, I could not type anything in terminal and iterm2 and hyper were crashing immediately after start.

With these changes, I was able to update my zsh via homebrew as suggested in the other answers by De_Vano and C.Nivs and all three apps worked as expected again. In my case a simple upgrade of zsh was enough. No need to reinstall and unlink.

coderuby
  • 1,188
  • 1
  • 11
  • 26
  • 5
    I have to switch to use /bin/bash first to use the terminal. Fix the problem as mentioned here, and change back to zsh – wanghq Nov 07 '18 at 19:59
3

After searching for a long time, this solved it for me:

brew reinstall ncurses
Andreas Bigger
  • 5,264
  • 1
  • 13
  • 18
0

I had the same issue and did not have an option to change the terminal on startup.

I ended up doing the following steps to resolve the problem:

  1. Create a new user on my mac & enable remote login for him.

  2. Login with the new user, which got a new working shell.

  3. Changing the shell of my original account back to bash, using the chsh command.

  4. Upgrading zsh using brew.

It Worked!

Filnor
  • 1,290
  • 2
  • 23
  • 28
0

If you facing the issue in iTerm2. You can simply change the path of your shell. Just go to iTerm2>>Preferences>>profile>>General>>command

Click on the dropdown and select Command and enter the command

/bin/zsh

This worked for me

0

execute this command

   chsh -s /bin/zsh                   
Grenoblois
  • 503
  • 1
  • 5
  • 19
0

This error is raised from "ncurses"

If you are using OSX without any system manager like Conda, try:

brew reinstall ncurses

If you are using Conda, activate your environment and try this:

conda install -y conda-forge::ncurses

Goodluck

Shrm
  • 426
  • 4
  • 8