redrabbit / git.limo

A Git source code management tool powered by Elixir with easy installation & high extensibility.
https://git.limo
MIT License
497 stars 42 forks source link

Failed to load NIF library: geef_nif.so: undefined symbol: #65

Closed ghost closed 4 years ago

ghost commented 4 years ago

Trying to compile gitgud will lead to the following error:

Debian (Docker (elixir-1.9.1 image) and Jessie (no Docker)):

23:28:53.168 [error] Process #PID<0.6967.0> raised an exception
** (RuntimeError) got 'Failed to load NIF library: \'/gitgud/_build/dev/lib/gitrekt/priv/geef_nif.so:                                undefined symbol: git_diff_to_buf\'' while retrieving Exception.message/1 for %RuntimeError{mes                               sage: 'Failed to load NIF library: \'/gitgud/_build/dev/lib/gitrekt/priv/geef_nif.so: undefined symbo                               l: git_diff_to_buf\''} (expected a string)
    lib/gitrekt/git.ex:120: GitRekt.Git.load_nif/0
    (kernel) code_server.erl:1340: anonymous fn/1 in :code_server.handle_on_load/5

Ubuntu (Docker (built from 18.04 image)):

23:28:53.168 [error] Process #PID<0.6967.0> raised an exception
** (RuntimeError) got 'Failed to load NIF library: \'/gitgud/_build/dev/lib/gitrekt/priv/geef_nif.so:                                undefined symbol: git_commit_committer\'' while retrieving Exception.message/1 for %RuntimeError{mes                               sage: 'Failed to load NIF library: \'/gitgud/_build/dev/lib/gitrekt/priv/geef_nif.so: undefined symbo                               l: git_commit_committer\''} (expected a string)
    lib/gitrekt/git.ex:120: GitRekt.Git.load_nif/0
    (kernel) code_server.erl:1340: anonymous fn/1 in :code_server.handle_on_load/5

Both use the same erlang + elixir version:

Erlang/OTP 22 [erts-10.5.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Elixir 1.9.1 (compiled with Erlang/OTP 20)

On Ubuntu the following libgit2-dev version is installed: v0.26.0 On Debian the following libgit2-dev version is installed: v0.25.1

This error seems to be (loosely) related to #61. However adding -Wl,--no-as-needed to gitrekt makefile does not resolve the issue for me.

I am opening this issue ticket here, because you maintainers know certainly more about geef than me. If this is a bug in geef, please open an issue on the related issue tracker.

ghost commented 4 years ago

Here's the log (from debian docker container): buildlog.txt

redrabbit commented 4 years ago

This error seems to be (loosely) related to #61. However adding -Wl,--no-as-needed to gitrekt makefile does not resolve the issue for me.

From your output logs, this seems very related to #61. Can you runldd on geef_nif.so (see comment) and paste the results here?

Did you modify the LD_FLAGS variable in Makefile as indicated here? Could you run make clean && make in apps/gitrekt and past the output here?

ghost commented 4 years ago

@redrabbit

From your output logs, this seems very related to #61. Can you runldd on geef_nif.so (see comment) and paste the results here?

root@gitgud1:/var/opt/gitgud/apps/gitrekt# ldd priv/geef_nif.so
    linux-vdso.so.1 (0x00007ffe37537000)
    libgit2.so.24 => /usr/lib/x86_64-linux-gnu/libgit2.so.24 (0x00007f3b7fdb7000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3b7fa18000)
    libcurl-gnutls.so.4 => /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 (0x00007f3b7f799000)
    libhttp_parser.so.2.1 => /usr/lib/x86_64-linux-gnu/libhttp_parser.so.2.1 (0x00007f3b7f592000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f3b7f378000)
    libssh2.so.1 => /usr/lib/x86_64-linux-gnu/libssh2.so.1 (0x00007f3b7f14b000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3b7ef43000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3b7ed26000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f3b802aa000)
    libnghttp2.so.14 => /usr/lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007f3b7eb00000)
    libidn2.so.0 => /usr/lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f3b7e8de000)
    librtmp.so.1 => /usr/lib/x86_64-linux-gnu/librtmp.so.1 (0x00007f3b7e6c1000)
    libpsl.so.5 => /usr/lib/x86_64-linux-gnu/libpsl.so.5 (0x00007f3b7e4b3000)
    libnettle.so.6 => /usr/lib/x86_64-linux-gnu/libnettle.so.6 (0x00007f3b7e27c000)
    libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f3b7dee3000)
    libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f3b7dc98000)
    libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f3b7d9be000)
    libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f3b7d78b000)
    libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f3b7d587000)
    liblber-2.4.so.2 => /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007f3b7d378000)
    libldap_r-2.4.so.2 => /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007f3b7d127000)
    libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f3b7ce17000)
    libunistring.so.0 => /usr/lib/x86_64-linux-gnu/libunistring.so.0 (0x00007f3b7cb00000)
    libhogweed.so.4 => /usr/lib/x86_64-linux-gnu/libhogweed.so.4 (0x00007f3b7c8cb000)
    libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f3b7c648000)
    libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f3b7c3e3000)
    libidn.so.11 => /lib/x86_64-linux-gnu/libidn.so.11 (0x00007f3b7c1af000)
    libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f3b7bf9c000)
    libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f3b7bd90000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3b7bb8c000)
    libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f3b7b988000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f3b7b771000)
    libsasl2.so.2 => /usr/lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007f3b7b556000)
    libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f3b7b342000)
    libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f3b7b139000)

ldd.txt

Did you modify the LD_FLAGS variable in Makefile as indicated here? Could you run make clean && make in apps/gitrekt and past the output here?

root@gitgud1:/var/opt/gitgud/apps/gitrekt# make clean                                        
rm -f -r c_src/library.o c_src/oid.o c_src/commit.o c_src/config.o c_src/reflog.o
c_src/revwalk.o c_src/pack.o c_src/reference.o c_src/tag.o c_src/index.o c_src/object.o c_src/geef.o
c_src/pathspec.o c_src/revparse.o c_src/diff.o c_src/blob.o c_src/signature.o c_src/tree.o
c_src/postgres_backend.o c_src/repository.o priv/geef_nif.so
root@gitgud1:/var/opt/gitgud/apps/gitrekt# cat Makefile                                      
ERLANG_PATH ?= $(shell erl -eval 'io:format("~s", [lists:concat([code:root_dir(), "/erts-", erlang:system_info(version), "/include"])])' -s init stop -noshell)
CFLAGS          ?= -O2 -Wall -Wextra -Wno-unused-parameter -I$(ERLANG_PATH)                  
LDFLAGS         += -Wl,--no-as-needed -lgit2                                                 

ifneq ($(OS),Windows_NT)                                                                     
        CFLAGS += -fPIC                                                                      
        ifeq ($(shell uname),Darwin)                                                         
                LDFLAGS += -dynamiclib -undefined dynamic_lookup                             
        endif                                                                                
endif                                                                                        

src = $(wildcard c_src/*.c)                                                                  
obj = $(src:.c=.o)                                                                           

all: priv/geef_nif.so                                                                        

priv/geef_nif.so: $(src)                                                                     
        @mkdir -p priv                                                                       
        $(CC) $(CFLAGS) -shared -w $(LDFLAGS) -o $@ $^                                       

clean:                                                                                       
        $(RM) -r $(obj) priv/geef_nif.so                                                     

.PHONY: clean                                   
root@gitgud1:/var/opt/gitgud/apps/gitrekt# make                                              
cc -O2 -Wall -Wextra -Wno-unused-parameter -I/usr/local/lib/erlang/erts-10.5.1/include -fPIC 
-shared -w -Wl,--no-as-needed -lgit2 -o priv/geef_nif.so c_src/library.c c_src/oid.c c_src/commit.c
c_src/config.c c_src/reflog.c c_src/revwalk.c c_src/pack.c c_src/reference.c c_src/tag.c
c_src/index.c c_src/object.c c_src/geef.c c_src/pathspec.c c_src/revparse.c c_src/diff.c
c_src/blob.c c_src/signature.c c_src/tree.c c_src/postgres_backend.c c_src/repository.c  

make.txt

After make, recompiling using mix compile --force does not change the error or output.

redrabbit commented 4 years ago

I've just tried with a fresh Ubuntu 19.04 and did not get any trouble compiling and running the server. I'll check with 18.04 asap.

Could you maybe try with Ubuntu 19.04. I don't really understand how we can get different results using Docker containers.

How did you install Elixir and Erlang? You are running 1.9.1 which is quite new. With the standard Ubuntu package repositories, I've got version 1.7.4 installed.

ghost commented 4 years ago

You are right, on 19.04 it works - but only with the changes to gitrekt's Makefile. libgit2-dev is 0.27.7 on 19.04 - I'll try to see if I can manually compile a newer version of libgit2 on 18.04 (or debian) and test if it's related to the version.

ghost commented 4 years ago

Update: I installed in the debian container libgit2-dev 0.27.4 from stretch-backports - with the backport I can successfully compile the application.

redrabbit commented 4 years ago

@CharlotteDunois did you have to update the Makefile as well with Debian or did it work out of the box?

ghost commented 4 years ago

@redrabbit I can confirm that it works out of the box with 0.27.4.