jwiegley / gitlib

180 stars 56 forks source link

hlibgit2 build failure on OS X El Capitan #60

Closed sgraf812 closed 7 years ago

sgraf812 commented 8 years ago

Hi,

El Capitano deprecated the OpenSSL for an in-house solution, according to brew install openssl:

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

This causes the following build failure:

...
    [49 of 49] Compiling Bindings.Libgit2 ( Bindings/Libgit2.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/Bindings/Libgit2.o )

    In file included from libgit2/src/attr.c:1:0: 

    In file included from libgit2/src/repository.h:16:0: 

    In file included from libgit2/src/index.h:11:0: 

    In file included from libgit2/src/filebuf.h:11:0: 

    In file included from libgit2/src/hash.h:22:0: 

    /private/var/folders/0t/cmszrwhn5znb_20t8yrhn61m0000gn/T/stack70283/hlibgit2-0.18.0.15/libgit2/src/hash/hash_openssl.h:13:10:
         fatal error: 'openssl/sha.h' file not found
    #include <openssl/sha.h>
             ^
    1 error generated.

A workaround for me is to brew link openssl --force and unlink after build, haven't tried the env variable way.

Well, that didn't work out too well. Had to rebuild my whole lts snapshot. Obviously this doesn't work in hindsight.

What works is passing the necessary paths to cabal/stack:

$ cabal/stack install hlibgit2-0.18.0.15 --extra-lib-dirs=/usr/local/opt/openssl/lib --extra-include-dirs=/usr/local/opt/openssl/include
madgen commented 7 years ago

Hello,

The referencing commit indeed solves this issue, but the latest release on Hackage is from December 2015. Is it possible to do a release so that the changes take effect?

For those who want to keep building in the process, if you're using Stack you may get around the issue by adding this to your stack.yaml under packages:

- location:
    git: git@github.com:jwiegley/gitlib.git
    commit: 4550f17bd38d720f66b791d92212c3452a0515d5
  subdirs:
    - hlibgit2
madgen commented 7 years ago

Is there a teeny-tiny minor release on sight perhaps @jwiegley?

jwiegley commented 7 years ago

@madgen Uploaded 0.18.0.16, please let me know if there are further issues.

madgen commented 7 years ago

Works brilliantly, thank you.