How to fix an issue with libgit2 after brew upgrade?
Asked Answered
H

4

10

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.

Hamo answered 13/2, 2024 at 11:56 Comment(3)
I was just running into a similar issue with libgit2.1.7 - I was able to get it working by running brew doctor and then resolving some of the issues it noted. For my setup, I ended up having to remove and reinstall some deprecated packages.Nosewheel
Thanks, forgot all about the doctor - ran it and had quite a few issues. Almost all resolved now, I do have some deprecated/disabled formulae, I like to keep around just for nostalgia, might need to find a better way to preserve theseThrilling
Recently started to encounter this issue when trying to use the bat utility. Thanks to the hint on the bat issue page this issue is now resolved for me. The solution was simple - just uninstall and install bat using Homebrew.Pet
C
32

Came across your question because I was having the same issue. After more research I found out the problem for me was specifically with the package exa. My .zshrc file had aliases for ls, ll, etc. that used this package. However, it is not maintained anymore. In fact, brew will yell if you try to upgrade it. My solution was to uninstall this package.

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 (examples below).

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

Then you need to source your .zshrc 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.

Cardiff answered 11/7, 2024 at 22:55 Comment(1)
That did the trick. Thank you!Hamo
P
8

i solved it with install the exact version via homebrew

brew install [email protected]
Pekingese answered 17/7, 2024 at 17:41 Comment(2)
Thanks, this worked for me observed the issue with batThrilling
I had the problem with cargo, when running topgrade. This answer (brew install [email protected]) fixed it for me, but additionally I had to something similar to what @alex-roberts said in his answer: cd /opt/homebrew/opt/libgit2/lib/ and then ln -s /opt/homebrew/opt/[email protected]/lib/libgit2.1.7.dylib .Border
P
5

I hit the same issue yesterday, and similar to the above fix I had to establish a symblink to get exa working again.

$ ln -s /opt/homebrew/opt/[email protected]/lib/libgit2.1.7.dylib /opt/homebrew/opt/libgit2/lib/libgit2.1.7.dylib

Poitiers answered 19/7, 2024 at 9:12 Comment(1)
This solution worked for me, too. brew install [email protected] didn't help because that version was already installed.Gleam
H
2

Here is one answer that I just tried, which worked, though I am not sure it is the best way to do this:

I did what I described in the "Update" to my question, namely cd /usr/local/opt/libgit2/lib/ followed by ln -s libgit2.1.7.2.dylib libgit2.1.6.dylib. Now ls is working again.

But is that the right way to fix this issue? It feels a bit like a hack that might cause other problems.

Hamo answered 13/2, 2024 at 12:47 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.