crystal-lang / crystal

The Crystal Programming Language
https://crystal-lang.org
Apache License 2.0
19.5k stars 1.62k forks source link

Running a program that requires ssl results in an error about missing dependencies #4245

Closed alexanderadam closed 7 years ago

alexanderadam commented 7 years ago

I'm running Crystal 0.21.1 [3c6c75e] (2017-03-06) LLVM 3.5.0 in Ubuntu 16.10.

When I'm trying to run a simple program like


require "http/web_socket"

uri = URI.parse "wss://echo.websocket.org"
HTTP::WebSocket.new uri

I'm getting the following error


$ crystal run src/foo.cr                                                                                 ⏎ master 
Package libssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libssl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libssl' found
Package libcrypto was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcrypto.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcrypto' found
or more verbose… ``` crystal run src/foo.cr -d --error-trace --verbose cc -o "/home/user/.cache/crystal/crystal-run-foo.tmp" "${@}" -rdynamic -lz `command -v pkg-config > /dev/null && pkg-config --libs libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs libcrypto || printf %s '-lcrypto'` -lpcre -lgc -lpthread /opt/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib _main.o S-lice40U-I-nt841.o P-ointer40U-I-nt841.o A-rgumentE-rror.o C-allS-tack.o A-rray40P-ointer40V-oid4141.o P-ointer40P-ointer40V-oid4141.o E-xception.o P-ointer40L-ibU-nwind5858E-xception41.o U-I-nt64.o U-I-nt8.o A-rray40S-tring41.o P-ointer40S-tring41.o S-taticA-rray40I-nt8443225641.o P-ointer40I-nt841.o I-nt32.o P-ointer40V-oid41.o F-iber.o T-hread.o S-et40T-hread41.o H-ash40T-hread4432N-il41.o P-ointer40H-ash58-5c8fd5776cf345ec94b91bf7a5f7e50f.o A-rray40I-nt3241.o S-tring5858B-uilder.o S-tring.o G-C-.o S-lice40T-41.o I-O-5858E-ncoder.o I-conv.o M-ath.o I-ndexE-rror.o E-rrno.o S-taticA-rray40U-I-nt84432102441.o C-har.o S-taticA-rray40U-I-nt84432441.o I-nvalidB-yteS-equenceE-rror.o S-taticA-rray40U-I-nt844326541.o D-ivisionB-yZ-ero.o P-ointer40I-nt3241.o U-I-nt32.o H-ash5858E-ntry40T-hread4432N-il41.o N-il.o D-eque40F-iber41.o P-ointer40F-iber41.o E-vent5858B-ase.o I-O-5858F-ileD-escriptor.o S-cheduler.o L-ibE-vent25858E-ventF-lags.o I-O-5858F-ileD-escriptor43.o E-vent5858E-vent.o U-N-I-X-S-erver.o I-nt64.o I-O-5858E-rror.o I-O-5858T-imeout.o E-xception43.o F-ile.o C-har5858R-eader.o R-ange40B-4432E-41.o R-ange40I-nt324432I-nt3241.o D-ebug5858E-L-F-.o D-ebug5858E-L-F-5858E-rror.o D-ebug5858E-L-F-5858E-ndianness.o D-ebug5858E-L-F-5858O-S-A-B-I-.o S-taticA-rray40U-I-nt84432409641.o I-O-5858E-O-F-E-rror.o D-ebug5858E-L-F-5858I-dent.o U-I-nt16.o I-O-5858B-yteF-ormat5858B-igE-ndian.o S-taticA-rray40U-I-nt84432241.o I-O-5858B-yteF-ormat5858L-ittleE-ndian.o D-ebug5858E-L-F-5858K-lass.o S-taticA-rray40U-I-nt84432841.o A-rray40D-ebug5858E-L-F-5858S-ectionH-eader41.o P-ointer40D-ebug5858E-L-F-5858S-ectionH-eader41.o I-O-5858S-eek.o D-ebug5858E-L-F-5858S-ectionH-eader.o I-O-5858D-ecoder.o D-ebug5858D-W-A-R-F-5858L-ineN-umbers.o A-rray40A-rray40D-d5580c0e9cb0bd8af7e90c96221706e1.o P-ointer40A-rray4-6533bdad81433bcf155b99ac74756686.o D-ebug5858D-W-A-R-F-5858L-ineN-umbers5858S-equence.o A-rray40T-uple40S-5992430a1a7ef1627717adfb71332538.o P-ointer40T-uple4-13415771527eed75ea796bf4f3711255.o A-rray40U-I-nt841.o I-nt8.o S-taticA-rray40U-I-nt84432141.o D-ebug5858D-W-A-R-F-.o D-ebug5858D-W-A-R-F-5858L-ineN-umbers5858R-egister.o D-ebug5858D-W-A-R-F-5858L-ineN-umbers5858R-ow.o A-rray40D-ebug585-1d195a7f864d2d3790ebeadd84b7a4df.o P-ointer40D-ebug5-a50eac5c43900f6bca76f68ff8c8549d.o D-ebug5858D-W-A-R-F-5858L-N-E-.o D-ebug5858D-W-A-R-F-5858L-N-S-.o P-roc40F-iber4432-6eb246a0a45118d3c5507cc830b14a70.o S-ignal.o P-roc40I-nt324432V-oid41.o E-vent5858S-ignalH-andler.o H-ash40S-ignal4432P-roc40S-ignal4432N-il4141.o P-ointer40H-ash58-ac8d12c9042874d67c1e049ddde35350.o H-ash5858E-ntry40-37a9b13947932e73bc9389d755897071.o E-vent5858S-ignalC-hildH-andler.o H-ash40I-nt324432P-rocess5858S-tatus41.o P-ointer40H-ash58-0a6eee72af0923261bdd3b6c7958da85.o H-ash40I-nt324432-12de0ef574784dde6ffe5b3ae93d5bba.o P-ointer40H-ash58-1ce4187043ca1e746f24acb8d0ff7a7e.o P-rocess5858S-tatus.o C-hannel5858B-uff-35976990a41c6a8201ab74e37227bdef.o C-hannel5858C-losedE-rror.o D-eque40P-rocess5858S-tatus3212432N-il41.o P-ointer40P-rocess5858S-tatus3212432N-il41.o H-ash5858E-ntry40-8e9a3cfcf19f0b3833711caadc35e784.o H-ash5858E-ntry40I-nt324432P-rocess5858S-tatus41.o I-O-.o S-taticA-rray40I-nt324432241.o A-tE-xitH-andlers.o A-rray40P-roc40I-nt324432N-il4141.o P-ointer40P-roc40I-nt324432N-il4141.o R-andom5858M-T-19937.o S-taticA-rray40U-I-nt324432441.o R-andom.o P-ointer40U-I-nt3241.o S-taticA-rray40U-I-nt32443262441.o L-ibC-rypto5858B-ioM-ethod.o B-ox40I-O-41.o F-ile5858P-R-eader.o F-late5858R-eader.o F-late5858W-riter.o S-taticA-rray40U-I-nt84432819241.o G-zip5858R-eader.o G-zip5858W-riter.o L-ibZ-5858Z-S-tream.o L-ibZ-5858E-rror.o F-late5858E-rror.o G-zip5858H-eader.o H-T-T-P-5858C-hunkedC-ontent.o H-T-T-P-5858S-erver5858R-esponse.o H-T-T-P-5858S-erver5858R-esponse5858O-utput.o H-T-T-P-5858H-eaders.o H-T-T-P-5858H-eaders5858K-ey.o H-ash40H-T-T-P-58-41c1f5416a58e3dc1fda537ff9025bc1.o P-ointer40H-ash58-dd9a6e4d9abdd280a27441daa00f6c79.o H-ash5858E-ntry40-d0d0f6cf0294ca93e95889559764778b.o H-T-T-P-5858C-ookies.o H-ash40S-tring4432H-T-T-P-5858C-ookie41.o P-ointer40H-ash58-7f71784838e8b236fae65568b2cec8a7.o A-rray40H-T-T-P-5858C-ookie41.o P-ointer40H-T-T-P-5858C-ookie41.o H-T-T-P-5858C-ookie.o U-R-I-.o T-uple40C-har4432C-har4432C-har4432C-har41.o H-T-T-P-.o T-ime.o T-ime5858K-ind.o P-ointer40L-ibC-5858T-m41.o T-ime5858F-ormat.o T-ime5858F-ormat5858F-ormatter.o H-T-T-P-5858U-nknownL-engthC-ontent.o H-T-T-P-5858W-ebS-4cb2ca367ffc5472ff9cc10ba3782e30.o H-T-T-P-5858W-ebS-ocket5858P-rotocol.o I-O-5858H-exdump.o O-penS-S-L-5858S-S-L-5858S-ocket43.o I-O-5858A-R-G-F-.o I-O-5858D-elimited.o I-O-5858M-emory.o I-O-5858M-ultiW-riter.o A-rray40I-O-41.o P-ointer40I-O-41.o H-T-T-P-5858F-ixedL-engthC-ontent.o I-O-5858S-ized43.o O-penS-S-L-5858S-S-L-5858E-rror.o L-ibS-S-L-5858S-S-L-E-rror.o U-nicode5858C-aseO-ptions.o U-nicode.o A-rray40T-uple40I-nt324432I-nt324432I-nt324141.o P-ointer40T-uple40I-nt324432I-nt324432I-nt324141.o A-rray40T-uple40I-nt324432I-nt324141.o P-ointer40T-uple40I-nt324432I-nt324141.o H-ash40I-nt324432-75cf0889665a4e7008b9d865daf34063.o P-ointer40H-ash58-97350088e56a60a6ff2710687e194b31.o H-ash5858E-ntry40-2cbbc8b2d8a06e2b1695995f1b4f7cb2.o G-zip5858H-eader5858F-lg.o C-R-C-32.o T-uple40U-I-nt644432U-I-nt6441.o E-numerable5858E-mptyE-rror.o G-zip5858E-rror.o S-taticA-rray40U-I-nt844321041.o S-tring5858T-oU-64I-nfo.o U-R-I-5858P-arser.o U-R-I-5858E-rror.o H-T-T-P-5858W-ebS-ocket.o T-C-P-S-ocket.o L-ibC-5858A-ddrinfo.o S-ocket5858F-amily.o S-ocket5858T-ype.o S-ocket5858P-rotocol.o S-ocket5858E-rror.o S-ocket5858A-ddrinfo.o P-ointer40L-ibC-5858S-ockaddrI-n641.o P-ointer40L-ibC-5858S-ockaddrI-n41.o T-C-P-S-ocket43.o O-penS-S-L-5858S-S-L-5858C-ontext5858C-lient.o O-penS-S-L-5858E-rror.o L-ibS-S-L-5858O-ptions.o L-ibS-S-L-5858M-odes.o O-penS-S-L-5858S-S-L-5858S-ocket5858C-lient.o O-penS-S-L-5858B-I-O-.o S-taticA-rray40U-I-nt844321641.o B-ase64.o P-ointer5858A-ppender40T-41.o P-ointer5858A-ppender40U-I-nt841.o H-T-T-P-5858R-equest.o H-T-T-P-5858P-arams.o H-ash40S-tring4432A-rray40S-tring4141.o P-ointer40H-ash58-e9dd6a6ea1a28a8606c1eb0818a2e511.o H-ash5858E-ntry40S-tring4432A-rray40S-tring4141.o H-T-T-P-5858P-arams5858B-uilder.o H-T-T-P-5858C-lient5858R-esponse.o H-T-T-P-5858B-odyT-ype.o H-T-T-P-5858C-omputedC-ontentT-ypeH-eader.o I-O-5858E-ncodingO-ptions.o S-ymbol.o L-E-B-R-eader.o L-ibU-nwind5858A-ction.o L-ibU-nwind5858R-easonC-ode.o C-allS-tack5858R-epeatedF-rame.o Package libssl was not found in the pkg-config search path. Perhaps you should add the directory containing `libssl.pc' to the PKG_CONFIG_PATH environment variable No package 'libssl' found Package libcrypto was not found in the pkg-config search path. Perhaps you should add the directory containing `libcrypto.pc' to the PKG_CONFIG_PATH environment variable No package 'libcrypto' found ```

Okay, sounds like a dependency issue, right? I also found another crystal user who had the same issue but in that case there were missing dependencies. I have no missing dependencies that are listed in the wiki.

And when I'm looking up the files /usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc and /usr/lib/x86_64-linux-gnu/pkgconfig/libcrypto.pc clearly exist.

The mentioned libraries should be installed as well. ``` $ aptitude search libssl | egrep "^i" i libssl-dev - Secure Sockets Layer toolkit - development files i A libssl-doc - Secure Sockets Layer toolkit - development documentation i libssl1.0.0 - Secure Sockets Layer toolkit - shared libraries i A libssl1.0.0:i386 - Secure Sockets Layer toolkit - shared libraries i libssl1.0.0-dbg - Secure Sockets Layer toolkit - debug information i libsslcommon2 - enterprise messaging system - common SSL libraries i libsslcommon2-dev - enterprise messaging system - common SSL development files $ aptitude search libcrypto | egrep "^i" i libcrypto++-dev - General purpose cryptographic library - C++ development i libcrypto++-utils - General purpose cryptographic library - utilities and data files i libcrypto++6 - General purpose cryptographic library - shared library ```

Do you have any idea what could be missing or what else to investigate?

PS: Thank you so much for Crystal!

refi64 commented 7 years ago

Sounds like a configuration issue with your system's version of pkg-config. Try running this first:

export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig
alexanderadam commented 7 years ago

@kirbyfan64 this works.

I did not change anything regarding these paths yet. This environment variable isn't set in my system per default. Where is LLVM/Crystal looking if this path isn't set or what could be the cause of the issue here? And how should I solve it permanently? Always set this environment variable in ~/.…_profile? If so, could it have a negative impact on other tools?

Should I close this issue here or could it be a Crystal / packaging issue?

PS: thank you for the fast response!

refi64 commented 7 years ago

@alexanderadam I'd just say that you should set it in ~/.profile. It shouldn't cause any harm.

What Linux distro do you have? I'd report this to the maintainers of the distro's pkg-config package and see what they say. pkg-config should be looking there by default if your distro is set up to install .pc files there.

alexanderadam commented 7 years ago

@kirbyfan64 I'm running Ubuntu 16.10. I will close this issue then. Thank you for your help!

EDIT: Turns out I have three pkg-config (Ubuntu, Linuxbrew and ChefDK). The Ubuntu binary is the only one finding all paths.

vascofernandes commented 7 years ago

I got exactly the problem a fresh installation of Ubuntu 17.04.

Installing libssl-dev solves the problem.

y4roslav commented 6 years ago

Just for history. The same issue at macOS 10.13+ Looks like this article is helping to deal with it

eduardo-mior commented 3 years ago

I had the same problem on an Alpine image in the docker.

I fixed this using the command:

RUN apk add libressl-dev

In my case I'm trying to use a package in GoLang that uses OpenSSL, so the complete command to solve my problem was:


RUN apk update && apk add --no-cache curl bash git gcc musl-dev pkgconfig libressl-dev python3-dev libffi-dev openssl-dev && curl https://glide.sh/get | sh```