martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
8.12k stars 269 forks source link

Can't find libgit2 on Mac/Homebrew #4115

Closed bklebe closed 1 month ago

bklebe commented 1 month ago

Description

Steps to Reproduce the Problem

  1. Run a brew upgrade for libgit2

Expected Behavior

jj works after the upgrade.

Actual Behavior

While upgrading other packages, Homebrew reports:

==> Checking for dependents of upgraded formulae...
Disable this behaviour by setting HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Reinstalling 1 dependent with broken linkage from source:
jj
==> Fetching dependencies for jj: pkg-config, libgit2@1.7, z3, llvm and rust
==> Fetching pkg-config
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/manifests/0.29.2_3
############################################################################################ 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/blobs/sha256:7b59abc0b5381065b1eab17421
############################################################################################ 100.0%
==> Fetching libgit2@1.7
==> Downloading https://ghcr.io/v2/homebrew/core/libgit2/1.7/manifests/1.7.2
############################################################################################ 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libgit2/1.7/blobs/sha256:0cad95e1f543ee0a6af1472c5
############################################################################################ 100.0%
==> Fetching z3
==> Downloading https://ghcr.io/v2/homebrew/core/z3/manifests/4.13.0
Already downloaded: /Users/bklebe/Library/Caches/Homebrew/downloads/f76733dc8564492bde6da5ddd68bf485a259b09d276de374047a4600ed52edff--z3-4.13.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/z3/blobs/sha256:d7a6ead5ea667caa7a45e1a623ecd386b0
Already downloaded: /Users/bklebe/Library/Caches/Homebrew/downloads/b83fa24637ba159214807443e0dada9de32c67d638c253cfb090a20ae9cfb096--z3--4.13.0.arm64_sonoma.bottle.tar.gz
==> Fetching llvm
==> Downloading https://ghcr.io/v2/homebrew/core/llvm/manifests/18.1.8
############################################################################################ 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/llvm/blobs/sha256:3a724923cede4bd596f0a4114c5fdf7e
############################################################################################ 100.0%
==> Fetching rust
==> Downloading https://ghcr.io/v2/homebrew/core/rust/manifests/1.79.0_1
############################################################################################ 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/rust/blobs/sha256:4a5bb56c4bd0737dc6d417ae69eb6759
############################################################################################ 100.0%
==> Fetching jj
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/566a76c1b35074fa9a0e724b20
############################################################################################ 100.0%
==> Downloading https://github.com/martinvonz/jj/archive/refs/tags/v0.19.0.tar.gz
==> Downloading from https://codeload.github.com/martinvonz/jj/tar.gz/refs/tags/v0.19.0
##=#=- #
==> Reinstalling jj
==> Installing dependencies for jj: pkg-config, libgit2@1.7, z3, llvm and rust
==> Installing jj dependency: pkg-config
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/manifests/0.29.2_3
Already downloaded: /Users/bklebe/Library/Caches/Homebrew/downloads/ac691fc7ab8ecffba32a837e7197101d271474a3a84cfddcc30c9fd6763ab3c6--pkg-config-0.29.2_3.bottle_manifest.json
==> Verifying attestation for pkg-config
==> Pouring pkg-config--0.29.2_3.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/pkg-config/0.29.2_3: 12 files, 679.3KB
==> Installing jj dependency: libgit2@1.7
==> Downloading https://ghcr.io/v2/homebrew/core/libgit2/1.7/manifests/1.7.2
Already downloaded: /Users/bklebe/Library/Caches/Homebrew/downloads/ecde05510a65fdaed70342439974074fb291160fa39ed3be025e2590f1a12133--libgit2@1.7-1.7.2.bottle_manifest.json
==> Verifying attestation for libgit2@1.7
==> Pouring libgit2@1.7--1.7.2.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libgit2@1.7/1.7.2: 105 files, 4.5MB
==> Installing jj dependency: z3
==> Downloading https://ghcr.io/v2/homebrew/core/z3/manifests/4.13.0
Already downloaded: /Users/bklebe/Library/Caches/Homebrew/downloads/f76733dc8564492bde6da5ddd68bf485a259b09d276de374047a4600ed52edff--z3-4.13.0.bottle_manifest.json
==> Verifying attestation for z3
==> Pouring z3--4.13.0.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/z3/4.13.0: 120 files, 31.1MB
==> Installing jj dependency: llvm
==> Downloading https://ghcr.io/v2/homebrew/core/llvm/manifests/18.1.8
Already downloaded: /Users/bklebe/Library/Caches/Homebrew/downloads/9d70a7262267fa7670ab51757d7337dbd8b6551585c152024416a738cd5d4172--llvm-18.1.8.bottle_manifest.json
==> Verifying attestation for llvm
==> Pouring llvm--18.1.8.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/llvm/18.1.8: 7,722 files, 1.8GB
==> Installing jj dependency: rust
==> Downloading https://ghcr.io/v2/homebrew/core/rust/manifests/1.79.0_1
Already downloaded: /Users/bklebe/Library/Caches/Homebrew/downloads/ed92306750efae0b4e20c97eb24f283cb49e16cd88c00f0f948aca8f64a942d8--rust-1.79.0_1.bottle_manifest.json
==> Verifying attestation for rust
==> Pouring rust--1.79.0_1.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/rust/1.79.0_1: 3,384 files, 292MB
==> Installing jj
==> cargo install --path=cli
Last 15 lines from /Users/bklebe/Library/Logs/Homebrew/jj/01.cargo:
      - /opt/homebrew/opt/libssh2/lib/pkgconfig
      - /opt/homebrew/opt/libgit2/lib/pkgconfig

  HINT: you may need to install a package such as libgit2, libgit2-dev or libgit2-devel.

  --- stderr
  thread 'main' panicked at /Users/bklebe/Library/Caches/Homebrew/cargo_cache/registry/src/index.crates.io-6f17d22bba15001f/libgit2-sys-0.16.2+1.7.2/build.rs:39:13:
  The environment variable `LIBGIT2_NO_VENDOR` has been set but no compatible system libgit2 could be found.
  The build is now aborting. To disable, unset the variable or use `LIBGIT2_NO_VENDOR=0`.

  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `jj-cli v0.19.0 (/private/tmp/jj-20240718-8193-acedpf/jj-0.19.0/cli)`, intermediate artifacts can be found at `/private/tmp/jj-20240718-8193-acedpf/jj-0.19.0/target`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

READ THIS: https://docs.brew.sh/Troubleshooting

These open issues may also help:
jj VCS cannot find correct libgit2 https://github.com/Homebrew/homebrew-core/issues/177686

(see also https://github.com/Homebrew/homebrew-core/issues/177686)

jj is now broken with a dyld error:

❯ jj                                                                                  at 10:51:14
dyld[11029]: 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

Specifications

PhilipMetzger commented 1 month ago

This seems to be a Homebrew issue, see https://github.com/martinvonz/jj/pull/4080#issuecomment-2236633319 aka (https://github.com/Homebrew/homebrew-core/issues/177686).

bklebe commented 1 month ago

This seems to be a Homebrew issue, see #4080 (comment) aka (Homebrew/homebrew-core#177686).

Ah, thanks. Best to close this then?

PhilipMetzger commented 1 month ago

We can keep it open until homebrew fixes it or close it whatever you prefer.

nicholasjng commented 1 month ago

Hey! I sent https://github.com/Homebrew/homebrew-core/pull/177765 to fix, please check if that solves the issue.

bklebe commented 1 month ago

Yes, it appears to be fixed for me. Thank you!

ilyagr commented 1 month ago

I think it's best to enable vendored-libgit2 feature permanently, see #4163 . This still allows linking libgit2 dynamically, and in a more predictable fashion, since the best way to do that seems to be an environment variable LIBGIT2_NO_VENDOR=1. I explained this more in the PR and a commit linked from it.

@nicholasjng (or anyone), let me know if this seems problematic. I'm not sure what Homebrew ended up doing, but I wanted to let you know about the environment variable in case you didn't know. https://github.com/rust-lang/git2-rs/pull/1065 might also be relevant (though I'm not sure if that gets merged).