Setting of LD_LIBRARY_PATH breaks curl

I have couchbase server installed in a docker container in /opt/couchbase and LD_LIBRARY_PATH environment set to:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/couchbase/lib

There seems to be issue however with the content of the /opt/couchbase/lib directory because it also contains

lrwxrwxrwx  1 couchbase couchbase       16 Sep 18  2015 libcurl.so -> libcurl.so.4.3.0
lrwxrwxrwx  1 couchbase couchbase       16 Sep 18  2015 libcurl.so.4 -> libcurl.so.4.3.0
-rw-r--r--  1 couchbase couchbase   405840 Sep 18  2015 libcurl.so.4.3.0

when I run curl I always get an error message:

root@srvr01:/opt/couchbase/lib# curl
curl: libcurl.so.4: no version information available (required by curl)
curl: try 'curl --help' or 'curl --manual' for more information

ldd shows that curl is forced (via LD_LIBRARY_PATH) to pick up libcurl in /opt/couchbase/lib first:


root@srvr01:/# ldd `which curl`
/usr/bin/curl: /opt/couchbase/lib/libcurl.so.4: no version information available (required by /usr/bin/curl)
	linux-vdso.so.1 (0x00007ffc29465000)
!!!!!!	libcurl.so.4 => /opt/couchbase/lib/libcurl.so.4 (0x00007fa755045000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fa754e25000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa754c07000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa75485c000)
	libssl.so.1.0.0 => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fa7545fb000)
	libcrypto.so.1.0.0 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fa7541fe000)
	/lib64/ld-linux-x86-64.so.2 (0x00005598875ac000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa753ffa000)

when I unset LD_LIBRARY_PATH then error message goes away, but of course some other things will probably break too since /opt/couchbase/lib contains much more. I can’t understand why couchbase installer brings the libcurl shared library on its own instead of relying on package dependendency management.

I believe it is a bug.
As a workaround I see only one viable option which is to delete libcurl* from /opt/couchbase/lib

Linux srvr01 4.4.0-22-generic #39-Ubuntu SMP Thu May 5 16:53:32 UTC 2016 x86_64 GNU/Linux

curl installed:

root@srvr01:/# curl --version
curl: /opt/couchbase/lib/libcurl.so.4: no version information available (required by curl)
curl 7.38.0 (x86_64-pc-linux-gnu) libcurl/7.40.0-DEV OpenSSL/1.0.1t zlib/1.2.8
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP 

Is it safe to remove libcurl* from /opt/couchbase/lib without breaking anything ?

why do you want to set LD_LIBRARY_PATH at all?

As I mentioned it is a docker container. I reused most of the official 4.0 Dockerfile: https://github.com/couchbase/docker/blob/3bd2525140309d7342d437c5691c729b35bd4cbb/community/couchbase-server/4.0.0/Dockerfile

Now I tried to download official couchbase:community-4.0.0 docker image and run it and LD_LIBRARY_PATH is set there as well:

root@3b8c7ab0a349:/# env | grep LD_LIB
LD_LIBRARY_PATH=:/opt/couchbase/lib

so I assume it is necessary for some reason

I moved this into wrapper, so that LD_LIBRARY_PATH affects only curl and will not be exported. Change is on Do not set global LD_LIBRARY_PATH to fix curl by avsej · Pull Request #39 · couchbase/docker · GitHub

@traun could you review it?