libgit2 / rugged

ruby bindings to libgit2
MIT License
2.24k stars 277 forks source link

extconf.rb doesn't find libgit2 from GNU Guix #955

Open Apteryks opened 1 year ago

Apteryks commented 1 year ago

Hello!

Based on my understanding of: https://github.com/libgit2/rugged/blob/6379f23cedd5f527cf6a5c229627e366b590a22d/ext/rugged/extconf.rb#L69, it should find the libgit2 prefix (LIBGIT2_DIR) using either a --with-git2-dir=$my-prefix passed to gem install, or automatically via pkg-config.

Neither works on my system, so I had to resort to manually patching LIBGIT2_DIR. pkg-config is available in the build environment and:

$ pkg-config --cflags libgit2
-I/gnu/store/agd3gdj1nhpq4w1hyfnhya66m9qlqfdk-libgit2-1.5.1/include -I/gnu/store/aj9iv9xfxb8bj8rg0r7v65xjh1skyb5k-openssl-1.1.1t/include -I/gnu/store/mqz2h2v1i7lx555yaz89sqd06kpgdr62-pcre2-10.37/include -I/gnu/store/v8d7j5i02nfz951x1szbl9xrd873vc3l-zlib-1.2.12/include

$ find /gnu/store/agd3gdj1nhpq4w1hyfnhya66m9qlqfdk-libgit2-1.5.1 -name version.h
/gnu/store/agd3gdj1nhpq4w1hyfnhya66m9qlqfdk-libgit2-1.5.1/include/git2/version.h

Thanks!

chrschmidt commented 1 year ago

I am new to ruby, and actually just want to package this like the original poster, but from reading the sources of the two functions, neither dir_config nor pkg_config will set up anything but variables that will later be written to the Makefile. Further more, while there is a check for pkg-config on the else half of the function, there is no check on the --use-system-libraries side.

I think what this code does, is extract the version of libgit2 that is bundled with rugged, and then check that the system libgit2 matches.

If the libgit2 tree has not been checked out it fails, despite the tree being used for nothing but extracting the major and minor version from version.h.

While I understand that it is inconvenient to have to update the version in extconf.rb manually, downloading an incomplete release (as the git submodule is missing), and then having to add the source from git just to compile against system libgit2 in the end, is also not a structurally sound path.

chrschmidt commented 1 year ago

$ pkg-config --cflags libgit2 -I/gnu/store/agd3gdj1nhpq4w1hyfnhya66m9qlqfdk-libgit2-1.5.1/include -I/gnu/store/aj9iv9xfxb8bj8rg0r7v65xjh1skyb5k-openssl-1.1.1t/include -I/gnu/store/mqz2h2v1i7lx555yaz89sqd06kpgdr62-pcre2-10.37/include -I/gnu/store/v8d7j5i02nfz951x1szbl9xrd873vc3l-zlib-1.2.12/include

I'd also like to point out to you that the check would fail on your system, because rugged is developed against libgit2 head (no specific commit IDs are set anywhere that I could find), and thus seems to require 1.6.x.