'Why am I missing git2.h and how do I get it back?
I am experiencing an odd problem every time I try the set-up of pygit2. Below is what I run and the error generated.
$ python3 setup.py install
running install
running build
running build_py
running build_ext
building '_pygit2' extension
/usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/lib -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -I/usr/local/include -Iinclude -I/usr/local/Cellar/python3/3.2.3/include/python3.2m -c src/pygit2.c -o build/temp.macosx-10.7-x86_64-3.2/src/pygit2.o
In file included from src/pygit2.c:32:
include/pygit2/error.h:6:10: fatal error: 'git2.h' file not found
#include <git2.h>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
I think I have successfully installed libgit2 (the build and make finished fine). Maybe it is a path issue? I have set LIBGIT2 environment variable to the src directory in the libgit2 folder. Is that the right place?
Solution 1:[1]
I never installed libgit2, but the following might help:
If your distro's repository contains libgit2, I'll advice to remove what you have compiled before and install libgit2 (binaries) and libgit2-dev (headers etc.) packages from the repo. This will place binaries and sources to the right directories.
Otherwise, try symlinking git2.h to /usr/local/include
Solution 2:[2]
It doesn't look like the LIBGIT2 variable took (could you show how you set the variable?) as the extra include directive uses /usr/local/include (which is the default).
The LIBGIT2 env var needs to be set to the prefix where the library was installed, typically /usr or /usr/local. It doesn't look like the library was installed to /usr/local as the compiler can't find it, so maybe you need export LIBGIT2=/usr before running setup.py.
Solution 3:[3]
Following step worked for me:
brew install libgit2
Solution 4:[4]
You must be on macOS. Here is how I solved the problem:
brew install libgit2
If that isn't working because of Permission denied @ dir_s_mkdir, just run the following command
sudo chown -R $(whoiam) $(brew --prefix)/*
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | dmytro |
| Solution 2 | Carlos MartÃn Nieto |
| Solution 3 | Shriram Bhosle |
| Solution 4 | Laurel |
