homebrewlslibgit2

How to fix an issue with libgit2 after brew upgrade?


On macOS 13.2, in zsh, ls returns the following error message:

dyld[15164]: Library not loaded: /usr/local/opt/libgit2/lib/libgit2.1.6.dylib
  Referenced from: <14346135-E664-31AF-A80B-05A5335ED5D7> /usr/local/Cellar/exa/0.10.1_1/bin/exa
  Reason: tried: '/usr/local/opt/libgit2/lib/libgit2.1.6.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/libgit2/lib/libgit2.1.6.dylib' (no such file), '/usr/local/opt/libgit2/lib/libgit2.1.6.dylib' (no such file), '/usr/local/lib/libgit2.1.6.dylib' (no such file), '/usr/lib/libgit2.1.6.dylib' (no such file, not in dyld cache), '/usr/local/Cellar/libgit2/1.7.2/lib/libgit2.1.6.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/Cellar/libgit2/1.7.2/lib/libgit2.1.6.dylib' (no such file), '/usr/local/Cellar/libgit2/1.7.2/lib/libgit2.1.6.dylib' (no such file), '/usr/local/lib/libgit2.1.6.dylib' (no such file), '/usr/lib/libgit2.1.6.dylib' (no such file, not in dyld cache)
zsh: abort      exa -1 --classify --group-directories-first

This seems to have started happening after a Homebrew upgrade.

I had hoped this answer would be what I needed, but I couldn't modify it to work for my case.

How can I fix this problem?


Update

Somehow the problem seems to be that the version of libgit2 in that directory is a more recent one but everything is still calling the old version: I went cd /usr/local/opt/libgit2/lib/ and found (using the Finder, not ls of course) that this directory contains libgit2.1.7.2.dylib but no libgit2.1.6.dylib. Maybe I should just make a symlink for that old version? Or would that cause other problems?

I tried brew unlink libgit2 then brew link libgit2; I tried brew uninstall libgit2 then brew install libgit2 and I tried installing the latest Command Line Tools, restarting the computer, etc. But I still have this problem.


Solution

  • The problem for me was with the package exa. My .zshrc file had aliases for ls, ll, etc. However, it is not maintained anymore. In fact, brew will yell if you try to upgrade it. My solution was first to uninstall this package, and then switch to eza

    brew uninstall exa
    

    And then install eza which is fork and is still maintained.

    brew install eza
    

    I then updated the aliases in my .zshrc file

    # map eza commands to normal ls commands
    alias ll="eza -l -g --icons"
    alias ls="eza --icons"
    

    Then load your .zshrc (or .aliases) file and you are all set.

    source ~/.zshrc
    

    I hope this helps if it is still an issue for you or anyone else that comes across this question.