ropensci / git2r

R bindings to the libgit2 library
https://docs.ropensci.org/git2r
GNU General Public License v2.0
215 stars 58 forks source link

Fails to build on Mac OSX because of missing header #354

Open rmendels opened 6 years ago

rmendels commented 6 years ago

This error prevents the installation of the Github version of pkgdown

devtools::install_github("ropensci/git2r")
Downloading GitHub repo ropensci/git2r@master
from URL https://api.github.com/repos/ropensci/git2r/zipball/master
Installing git2r
Running /Library/Frameworks/R.framework/Resources/bin/R CMD INSTALL \
  /private/var/folders/xw/mcmsdzzx4mgbttplylgs7ysh0000gp/T/RtmpGG3T9B/devtools7b027cf25463/ropensci-git2r-73db600 \
  '--library=/Users/rmendels/Library/R/3.5/library' --install-tests 
* installing *source* package ‘git2r’ ...
checking build system type... x86_64-apple-darwin17.6.0
checking host system type... x86_64-apple-darwin17.6.0
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for brew... yes
checking for pkg-config... no
** libs
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include   -fPIC  -Wall -g -O2  -c git2r.c -o git2r.o
git2r.c:31:10: fatal error: 'git2.h' file not found
#include <git2.h>
         ^~~~~~~~
1 error generated.
make: *** [git2r.o] Error 1
ERROR: compilation failed for package ‘git2r’
* removing ‘/Users/rmendels/Library/R/3.5/library/git2r’
* restoring previous ‘/Users/rmendels/Library/R/3.5/library/git2r’
Error in run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout),  : 
  System command error
stewid commented 6 years ago

Does it work if you first install libgit2 with brew?

stewid commented 6 years ago

I have updated the configuration error message with libgit2 installation instructions if libgit2 is not found on macOS. Hope that helps, else reopen the issue.

rmendels commented 6 years ago

I installed libgit2 with Brew. It now compiles, but I get the following error at the end:

installing to /Users/rmendels/Library/R/3.5/library/git2r/libs
** R
** inst
** tests
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘git2r’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so':
  dlopen(/Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so, 6): Symbol not found: _git_diff_print_callback__to_file_handle
  Referenced from: /Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so
  Expected in: flat namespace
 in /Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/rmendels/Library/R/3.5/library/git2r’
* restoring previous ‘/Users/rmendels/Library/R/3.5/library/git2r’
Error in run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout),  : 
  System command error
stewid commented 6 years ago

Thanks for reporting this

stewid commented 6 years ago

@rmendels could you please try again.

rmendels commented 6 years ago
installing to /Users/rmendels/Library/R/3.5/library/git2r/libs
** R
** inst
** tests
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘git2r’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so':
  dlopen(/Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so, 6): Symbol not found: _git_annotated_commit_free
  Referenced from: /Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so
  Expected in: flat namespace
 in /Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/rmendels/Library/R/3.5/library/git2r’
* restoring previous ‘/Users/rmendels/Library/R/3.5/library/git2r’
Error in run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout),  : 
  System command error
rmendels commented 6 years ago

I should add that the file that is trying to be loaded (git2r.so) does exist and the stated location, and it is 1.2MB - is that the correct size? And there is no other error or warning in the compile stage.

stewid commented 6 years ago

Are you using the gcc compiler? I think you need to use clang on macOS.

stewid commented 6 years ago

I think I found the problem in the configuration script. Could you please try again.

rmendels commented 6 years ago

Now I am having it not find libgit2, which was installed with home-brew and it was finding it yesterday. And I am definitely using the clang compiler. Can only work on this off and on today

stewid commented 6 years ago

@rmendels could you please try again.

rmendels commented 6 years ago
devtools::install_github("ropensci/git2r")
Downloading GitHub repo ropensci/git2r@master
from URL https://api.github.com/repos/ropensci/git2r/zipball/master
Installing git2r
Running /Library/Frameworks/R.framework/Resources/bin/R CMD \
  INSTALL \
  /private/var/folders/xw/mcmsdzzx4mgbttplylgs7ysh0000gp/T/Rtmp3lU8M7/devtools75b04e34602c/ropensci-git2r-d79ea6f \
  '--library=/Users/rmendels/Library/R/3.5/library' \
  --install-tests 
* installing *source* package ‘git2r’ ...
checking build system type... x86_64-apple-darwin17.6.0
checking host system type... x86_64-apple-darwin17.6.0
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for pkg-config... no
checking for brew... yes
checking whether the libgit2 version will work in git2r... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r.c -o git2r.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_S3.c -o git2r_S3.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_arg.c -o git2r_arg.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_blame.c -o git2r_blame.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_blob.c -o git2r_blob.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_branch.c -o git2r_branch.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_checkout.c -o git2r_checkout.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_clone.c -o git2r_clone.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_commit.c -o git2r_commit.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_config.c -o git2r_config.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_cred.c -o git2r_cred.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_diff.c -o git2r_diff.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_error.c -o git2r_error.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_graph.c -o git2r_graph.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_index.c -o git2r_index.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_libgit2.c -o git2r_libgit2.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_merge.c -o git2r_merge.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_note.c -o git2r_note.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_object.c -o git2r_object.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_odb.c -o git2r_odb.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_oid.c -o git2r_oid.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_push.c -o git2r_push.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_reference.c -o git2r_reference.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_reflog.c -o git2r_reflog.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_remote.c -o git2r_remote.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_repository.c -o git2r_repository.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_reset.c -o git2r_reset.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_revparse.c -o git2r_revparse.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_revwalk.c -o git2r_revwalk.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_signature.c -o git2r_signature.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_stash.c -o git2r_stash.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_status.c -o git2r_status.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_tag.c -o git2r_tag.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_transfer.c -o git2r_transfer.o
/usr/local/clang4/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -Wall -g -O2 -I/usr/local/opt/libgit2/include -fPIC  -Wall -g -O2  -c git2r_tree.c -o git2r_tree.o
/usr/local/clang4/bin/clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/clang4/lib -o git2r.so git2r.o git2r_S3.o git2r_arg.o git2r_blame.o git2r_blob.o git2r_branch.o git2r_checkout.o git2r_clone.o git2r_commit.o git2r_config.o git2r_cred.o git2r_diff.o git2r_error.o git2r_graph.o git2r_index.o git2r_libgit2.o git2r_merge.o git2r_note.o git2r_object.o git2r_odb.o git2r_oid.o git2r_push.o git2r_reference.o git2r_reflog.o git2r_remote.o git2r_repository.o git2r_reset.o git2r_revparse.o git2r_revwalk.o git2r_signature.o git2r_stash.o git2r_status.o git2r_tag.o git2r_transfer.o git2r_tree.o -L/usr/local/opt/libgit2/lib -lgit2 -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Users/rmendels/Library/R/3.5/library/git2r/libs
** R
** inst
** tests
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘git2r’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so':
  dlopen(/Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so, 6): Library not loaded: /usr/local/opt/libssh2/lib/libssh2.1.dylib
  Referenced from: /usr/local/opt/libgit2/lib/libgit2.27.dylib
  Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/rmendels/Library/R/3.5/library/git2r’
* restoring previous ‘/Users/rmendels/Library/R/3.5/library/git2r’
Error in run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout),  : 
  System command error
jennybc commented 6 years ago

As a general rule, it might be best to use remotes::install_github() instead of devtools::install_github(), because the former does not use git2r itself. I have no idea if that matters here on MacOS (it does on Windows), but it eliminates one potential source of spurious failures.

rmendels commented 6 years ago

What started this is I was trying to install pkgdown from Github, which installs git2r from Github, so it isn't just a question of my own install, but what will/will not work with the pkgdown install.

Thanks.

rmendels commented 6 years ago

Just tried it using remotes::install_github("ropensci/git2r")

installing to /Users/rmendels/Library/R/3.5/library/git2r/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘git2r’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so':
  dlopen(/Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so, 6): Library not loaded: /usr/local/opt/libssh2/lib/libssh2.1.dylib
  Referenced from: /usr/local/opt/libgit2/lib/libgit2.27.dylib
  Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/rmendels/Library/R/3.5/library/git2r’
* restoring previous ‘/Users/rmendels/Library/R/3.5/library/git2r’
Warning message:
In i.p(...) :
  installation of package ‘/var/folders/xw/mcmsdzzx4mgbttplylgs7ysh0000gp/T//Rtmp3lU8M7/remotes75b073cc1814/ropensci-git2r-d79ea6f’ had non-zero exit status
jennybc commented 6 years ago

Note the error is now about libssh2.

rmendels commented 6 years ago

Beyond what I can resolve. I am just trying to get the Github version of pkgdown installed (because the CRAN version fails on one of my packages which I have reported), which tries to install git2r, which fails on my system. So I am reporting what I have found. I am always suspicious when you are depending on things installed by homebrew, because that changes the locations of where a lot of things are assumed to be located. I think I will just wait this one out until new versions are on CRAN, or happy to test if it appears solutions have been found.

jennybc commented 6 years ago

Got it. It is frustrating. A release of git2r is on the horizon.

jeroen commented 6 years ago

Should be fixed now?

rmendels commented 6 years ago

I am happy to test, but will wait till I can get binaries from CRAN. And as I show above, I am using the clang4 compiler. I have successfully compiled any number of other packages.

installing to /Users/rmendels/Library/R/3.5/library/git2r/libs
** R
** inst
** tests
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘git2r’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so':
  dlopen(/Users/rmendels/Library/R/3.5/library/git2r/libs/git2r.so, 6): Library not loaded: /usr/local/opt/libssh2/lib/libssh2.1.dylib
  Referenced from: /usr/local/opt/libgit2/lib/libgit2.27.dylib
  Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/rmendels/Library/R/3.5/library/git2r’
* restoring previous ‘/Users/rmendels/Library/R/3.5/library/git2r’
Error in run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout),  : 
  System command error
ninakhera commented 1 year ago

I'm dealing with a similar issue! Has this been resolved?


"Error: package or namespace load failed for ‘git2r’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/ninakhera/miniconda3/envs/ninaEnv/lib/R/library/00LOCK-git2r/00new/git2r/libs/git2r.dylib':
  dlopen(/Users/ninakhera/miniconda3/envs/ninaEnv/lib/R/library/00LOCK-git2r/00new/git2r/libs/git2r.dylib, 6): Symbol not found: _git_diff_print_callback__to_file_handle
  Referenced from: /Users/ninakhera/miniconda3/envs/ninaEnv/lib/R/library/00LOCK-git2r/00new/git2r/libs/git2r.dylib
  Expected in: flat namespace
 in /Users/ninakhera/miniconda3/envs/ninaEnv/lib/R/library/00LOCK-git2r/00new/git2r/libs/git2r.dylib
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/ninakhera/miniconda3/envs/ninaEnv/lib/R/library/git2r’"