Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find libgit2 on Mac/Homebrew #4115

Closed
bklebe opened this issue Jul 18, 2024 · 6 comments
Closed

Can't find libgit2 on Mac/Homebrew #4115

bklebe opened this issue Jul 18, 2024 · 6 comments
Labels

Comments

@bklebe
Copy link

bklebe commented Jul 18, 2024

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 Homebrew/homebrew-core#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

  • Platform: macOS Sonoma 14.5
  • Version: jj 0.19.0, libgit2 1.7.2 -> 1.8.1 (appears to be broken by upgrade)
@PhilipMetzger
Copy link
Collaborator

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

@bklebe
Copy link
Author

bklebe commented Jul 18, 2024

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

Ah, thanks. Best to close this then?

@PhilipMetzger
Copy link
Collaborator

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

@nicholasjng
Copy link

Hey! I sent Homebrew/homebrew-core#177765 to fix, please check if that solves the issue.

@bklebe
Copy link
Author

bklebe commented Jul 23, 2024

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

@bklebe bklebe closed this as completed Jul 23, 2024
ilyagr added a commit to ilyagr/jj that referenced this issue Jul 26, 2024
…link libgit2

This changes less than it seems. Our CI builds already mostly linked a vendored
copy of libgit2. This is because before this commit, it turns out that `git2`
could link `libgit2` *either* statically or dynamically based on whether it could
find a version of libgit2 it liked to link dynamically. Our CI builds usually did
not provide such a version AFAIK.

This made the kind of binary `cargo install` would produce unpredictable and may
have contributed to martinvonz#2896.

Instead, if a packager wants to link `libgit2` dynamically, they should set an
environment variable, as described inside the diff of this commit. I also think
we should recommend static linking as `git2` is quite picky about the versions of
`libgit2` it supports. See also rust-lang/git2-rs#1073

This might be related to martinvonz#4115.
ilyagr added a commit to ilyagr/jj that referenced this issue Jul 26, 2024
…link libgit2

This changes less than it seems. Our CI builds already mostly linked a vendored
copy of libgit2. This is because before this commit, it turns out that `git2`
could link `libgit2` *either* statically or dynamically based on whether it could
find a version of libgit2 it liked to link dynamically. Our CI builds usually did
not provide such a version AFAIK.

This made the kind of binary `cargo install` would produce unpredictable and may
have contributed to martinvonz#2896.

Instead, if a packager wants to link `libgit2` dynamically, they should set an
environment variable, as described inside the diff of this commit. I also think
we should recommend static linking as `git2` is quite picky about the versions of
`libgit2` it supports. See also rust-lang/git2-rs#1073

This might be related to martinvonz#4115.
@ilyagr
Copy link
Collaborator

ilyagr commented Jul 26, 2024

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. rust-lang/git2-rs#1065 might also be relevant (though I'm not sure if that gets merged).

ilyagr added a commit to ilyagr/jj that referenced this issue Jul 26, 2024
…link libgit2

This changes less than it seems. Our CI builds already mostly linked a vendored
copy of libgit2. This is because before this commit, it turns out that `git2`
could link `libgit2` *either* statically or dynamically based on whether it could
find a version of libgit2 it liked to link dynamically. Our CI builds usually did
not provide such a version AFAIK.

This made the kind of binary `cargo install` would produce unpredictable and may
have contributed to martinvonz#2896.  I was once very surprised when I did `brew upgrade libgit2` and then
`cargo build --release` suddenly switched from building dynamically linked `jj` to the vendored version.

Instead, if a packager wants to link `libgit2` dynamically, they should set an
environment variable, as described inside the diff of this commit. I also think
we should recommend static linking as `git2` is quite picky about the versions of
`libgit2` it supports. See also rust-lang/git2-rs#1073

This might be related to martinvonz#4115.
ilyagr added a commit to ilyagr/jj that referenced this issue Jul 28, 2024
…link libgit2

This changes less than it seems. Our CI builds already mostly linked a vendored
copy of libgit2. This is because before this commit, it turns out that `git2`
could link `libgit2` *either* statically or dynamically based on whether it could
find a version of libgit2 it liked to link dynamically. Our CI builds usually did
not provide such a version AFAIK.

This made the kind of binary `cargo install` would produce unpredictable and may
have contributed to martinvonz#2896.  I was once very surprised when I did `brew upgrade libgit2` and then
`cargo build --release` suddenly switched from building dynamically linked `jj` to the vendored version.

Instead, if a packager wants to link `libgit2` dynamically, they should set an
environment variable, as described inside the diff of this commit. I also think
we should recommend static linking as `git2` is quite picky about the versions of
`libgit2` it supports. See also rust-lang/git2-rs#1073

This might be related to martinvonz#4115.
ilyagr added a commit that referenced this issue Jul 28, 2024
…link libgit2

This changes less than it seems. Our CI builds already mostly linked a vendored
copy of libgit2. This is because before this commit, it turns out that `git2`
could link `libgit2` *either* statically or dynamically based on whether it could
find a version of libgit2 it liked to link dynamically. Our CI builds usually did
not provide such a version AFAIK.

This made the kind of binary `cargo install` would produce unpredictable and may
have contributed to #2896.  I was once very surprised when I did `brew upgrade libgit2` and then
`cargo build --release` suddenly switched from building dynamically linked `jj` to the vendored version.

Instead, if a packager wants to link `libgit2` dynamically, they should set an
environment variable, as described inside the diff of this commit. I also think
we should recommend static linking as `git2` is quite picky about the versions of
`libgit2` it supports. See also rust-lang/git2-rs#1073

This might be related to #4115.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants