Homebrew / homebrew-core

🍻 Default formulae for the missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
13.69k stars 12.39k forks source link

jj VCS cannot find correct libgit2 #177686

Closed nicholasjng closed 2 months ago

nicholasjng commented 2 months ago

brew gist-logs <formula> link OR brew config AND brew doctor output

~
➜ brew gist-logs jj
Error: No logs.

~
➜ brew config
HOMEBREW_VERSION: 4.3.9
ORIGIN: https://github.com/Homebrew/brew
HEAD: 1c98a33a376e5b35ebc801d0f7d6ba7b9eb118ac
Last commit: 10 days ago
Core tap JSON: 18 Jul 05:25 UTC
Core cask tap JSON: 18 Jul 05:25 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: hx
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 3.3.3 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.3/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 15.0.0 build 1500
Git: 2.45.2 => /opt/homebrew/bin/git
Curl: 8.6.0 => /usr/bin/curl
macOS: 14.5-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: 15.4
Rosetta 2: false

~
➜ brew doctor
Your system is ready to brew.

Verification

What were you trying to do (and why)?

Tried to follow the jujutsu VCS tutorial yesterday, got a dyld error about it being unable to locate the correct libgit2 version. It seems that it explicitly searches for libgit2@1.7, but the formula depends on libgit2 as of this writing:

➜ brew info jj
==> jj: stable 0.19.0 (bottled), HEAD
Git-compatible distributed version control system
https://github.com/martinvonz/jj
Installed
/opt/homebrew/Cellar/jj/0.19.0 (14 files, 15.8MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-07-18 at 07:27:35
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/j/jj.rb
License: Apache-2.0
==> Dependencies
Build: pkg-config ✔, rust ✔
Required: libgit2 ✔, openssl@3 ✔
==> Options
--HEAD
    Install HEAD version
==> Caveats
zsh completions have been installed to:
  /opt/homebrew/share/zsh/site-functions
==> Analytics
install: 647 (30 days), 1,846 (90 days), 4,397 (365 days)
install-on-request: 648 (30 days), 1,846 (90 days), 4,397 (365 days)
build-error: 14 (30 days)

When I list libgit2's lib folder, it shows me the versioned dylib for libgit2 v1.8.1:

~
➜ ls /opt/homebrew/opt/libgit2/lib
libgit2.1.8.1.dylib libgit2.1.8.dylib   libgit2.a           libgit2.dylib       pkgconfig

So this seems to be a version mismatch of libgit2 for the jj formula.

What happened (include all command output)?

~
➜ jj --version
dyld[73987]: Library not loaded: /opt/homebrew/opt/libgit2/lib/libgit2.1.7.dylib
  Referenced from: <E8960ED2-AAE3-34EB-9B6F-057F96828A15> /opt/homebrew/Cellar/jj/0.19.0/bin/jj
  Reason: tried: '/opt/homebrew/opt/libgit2/lib/libgit2.1.7.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/libgit2/lib/libgit2.1.7.dylib' (no such file), '/opt/homebrew/opt/libgit2/lib/libgit2.1.7.dylib' (no such file), '/opt/homebrew/Cellar/libgit2/1.8.1/lib/libgit2.1.7.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/libgit2/1.8.1/lib/libgit2.1.7.dylib' (no such file), '/opt/homebrew/Cellar/libgit2/1.8.1/lib/libgit2.1.7.dylib' (no such file)
zsh: abort      jj

What did you expect to happen?

jj just printing me the version.

Step-by-step reproduction instructions (by running brew commands)

brew install jj
jj --version
igorepst commented 2 months ago

Sam thing happens for bat after the recent update

bat --version
dyld[73308]: Library not loaded: /opt/homebrew/opt/libgit2@1.7/lib/libgit2.1.7.dylib
Referenced from: <968B81E5-4BAB-323C-8FD5-1BFB54F3052D> /opt/homebrew/Cellar/bat/0.24.0_1/bin/bat
Reason: tried: '/opt/homebrew/opt/libgit2@1.7/lib/libgit2.1.7.dylib' (no such file), 
'/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/libgit2@1.7/lib/libgit2.1.7.dylib' (no such file), 
'/opt/homebrew/opt/libgit2@1.7/lib/libgit2.1.7.dylib' (no such file), '/opt/homebrew/Cellar/libgit2/1.8.1/lib/libgit2.1.7.dylib' (no 
such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/libgit2/1.8.1/lib/libgit2.1.7.dylib' (no such file), 
'/opt/homebrew/Cellar/libgit2/1.8.1/lib/libgit2.1.7.dylib' (no such file)
darthShadow commented 2 months ago

Similar issue with gping too.

Had to run brew missing to find the correct missing dependencies, which turned out to be libgit2@1.7. Installing that fixed the error.

nicholasjng commented 2 months ago

Had to run brew missing to find the correct missing dependencies, which turned out to be libgit2@1.7. Installing that fixed the error.

Just for further information, brew doctor suggested this too, but that did not fix it for me. From what I can see, the reason here is the dyld only considers brew --prefix libgit2 and /opt/homebrew/Cellar/libgit2/1.8.1/ as a library search path, but not brew --prefix libgit2@1.7.

darthShadow commented 2 months ago

Yeah, I think jj just got missed in the libgit2 bump recently: https://github.com/Homebrew/homebrew-core/pull/166767

It looks like the latest version still dependends on 1.7.2 (https://github.com/martinvonz/jj/blob/74c275ed10a7b45e1638fb00e53e29bc6286e8ba/Cargo.lock#L1828), so an explicity dependency to that version should have been added just like bat or gping.

carlocab commented 2 months ago

jj needs to be switched to libgit2@1.7 and a revision bump -- please feel free to open a PR doing so.

The others (e.g. bat and gping) should be fixed by

brew install libgit2@1.7

To be clear: manually installing libgit2@1.7 is, of course, a workaround. We hope to have it fixed properly soon.

cho-m commented 2 months ago

In case of jj and git-interactive-rebase-tool, it looks like dependent tests were skipped in PR. I don't think we had any CI labels to do this so not sure what happened there. May need to watch out in case this is a bug in our CI workflow.

alex commented 2 months ago

I think cargo-outdated likely needs to be switched to libgit2@1.7, is anything needed besides that switch in a PR?

carlocab commented 2 months ago

I think cargo-outdated likely needs to be switched to libgit2@1.7, is anything needed besides that switch in a PR?

Just a revision bump as well, but that should be it!

yarenty commented 1 month ago

for impatient:

brew install libgit2@1.7

ln -s /usr/local/Cellar/libgit2@1.7/1.7.2/lib/libgit2.1.7.2.dylib  /usr/local/opt/libgit2/lib/libgit2.1.7.dylib
carlocab commented 1 month ago

for impatient:

brew install libgit2@1.7

ln -s /usr/local/Cellar/libgit2@1.7/1.7.2/lib/libgit2.1.7.2.dylib  /usr/local/opt/libgit2/lib/libgit2.1.7.dylib

There shouldn't be any need to do this. You just need to brew update && brew upgrade.