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

libgit2 found for linking, but not loading (i.e. missing rpath). #1138

Open
reitermarkus opened this issue Mar 6, 2025 · 0 comments
Open

Comments

@reitermarkus
Copy link

reitermarkus commented Mar 6, 2025

I have a build script using git2, which builds fine, but when it is executed, fails with:

/target/debug/build/built2-42d7a0628db36d4d/build-script-build: error while loading shared libraries: libgit2.so.1.9: cannot open shared object file: No such file or directory

The problem is libgit2.so.1.9 is found in /home/linuxbrew/.linuxbrew/Cellar/libgit2/1.9.0/lib/libgit2.so.1.9 (via Homebrew-installed pkg-config), but when executing cannot find it since it is not in the load path.

Ideally, the libgit2-sys build script should add that directory as rpath, but cargo has no way of forwarding this to a dependent binary (yet) using e.g. cargo:rustc-link-arg.

For normal binaries, you can hack the rpath into build.rs, but there is no way to set it for the build.rs itself other than setting RUSTFLAGS manually.

Maybe there is a way to detect when a package is found with pkg-config but cannot actually be loaded (e.g. using ldconfig -p) and fall back to using the vendored version in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant