dom96 / choosenim

Tool for easily installing and managing multiple versions of the Nim programming language.
BSD 3-Clause "New" or "Revised" License
680 stars 64 forks source link

Install fails on Ubuntu 22.04 (could not load: libcrypto.so) #297

Closed joenano closed 2 years ago

joenano commented 2 years ago

curl https://nim-lang.org/choosenim/init.sh -sSf | sh

choosenim-init: Downloading choosenim-0.8.2_linux_amd64
could not load: libcrypto.so(.1.1|.1.0.2|.1.0.1|.1.0.0|.0.9.9|.0.9.8|.48|.47|.46|.45|.44|.43|.41|.39|.38|.10|)
(compile with -d:nimDebugDlOpen for more information)

openssl version

OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)

ldconfig -p | grep libcrypto

libcrypto.so.3 (libc6,x86-64) => /lib/x86_64-linux-gnu/libcrypto.so.3
libcrypto.so.3 (libc6) => /lib/i386-linux-gnu/libcrypto.so.3
joenano commented 2 years ago

apt install libssl-dev seems to address this but now

curl https://nim-lang.org/choosenim/init.sh -sSf | sh

choosenim-init: Downloading choosenim-0.8.2_linux_amd64
could not import: SSL_get_peer_certificate
joenano commented 2 years ago

some more info that seems to be related

nim: incompatible with OpenSSL 3.0

The nim source package currently has a hard-coded build-dependency (and runtime dependency) on libssl1.1. Attempting to switch to libssl3 results in an unusable binary:

libssl3 is currently in experimental and expected to be the version of OpenSSL shipped with the next version of Debian. Please work with upstream to ensure this package can be updated for compatibility with OpenSSL 3.

Here is a (not comprehensive or entirely accurate) attempt to check for use of obsolete symbols by nim:

$ for sym in $(sed -n -e'/proc.dynlib:/ { s/^\sproc\s+//; s/*(.//; p }' lib/wrappers/openssl.nim); do objdump -T /usr/lib/x86_64-linux-gnu/libssl.so.3 /usr/lib/x86_64-linux-gnu/libcrypto.so.3 |grep -q $sym\$ || echo "missing symbol $sym"; done missing symbol SSL_library_init missing symbol SSL_load_error_strings missing symbol SSLv23_method missing symbol SSLeay missing symbol SSL_state missing symbol SSLv23_client_method missing symbol SSLv2_method missing symbol SSLv3_method missing symbol SSL_CTX_get_ex_new_index missing symbol bioNew missing symbol bioFreeAll missing symbol bioSMem missing symbol bioCtrlPending missing symbol ErrClearError missing symbol ErrFreeStrings missing symbol ErrRemoveState missing symbol SSL_get_peer_certificate

joenano commented 2 years ago

The solution was installing openssl 1, there is an issue open in nim to support openssl 3 which doesnt seem to be high priority so I will close this.

Perhaps the readme should be updated to reflect incompatibility with Openssl 3.

dom96 commented 2 years ago

choosenim aims to work out of the box, so we should fix this

creikey commented 2 years ago

The solution was installing openssl 1, there is an issue open in nim to support openssl 3 which doesnt seem to be high priority so I will close this.

Perhaps the readme should be updated to reflect incompatibility with Openssl 3.

For those wondering how to do this I followed https://askubuntu.com/questions/1403837/how-do-i-use-openssl-1-1-1-in-ubuntu-22-04 In installing openssl 1.1.1 to /usr/local/ssl Then ran export LD_LIBRARY_PATH=/usr/local/ssl/lib before running choosenim and it seems to work. I've also added export LD_LIBRARY_PATH=/usr/local/ssl/lib to my bashrc

orz-- commented 2 years ago

I think OpenSSL 3.0 is a new major version, not an experimental version. New distributions are adopting this version. ex.Ubuntu 22.04, Fedora36 ...

I would like to you to fix it soon or announce creikey-san solution.

13r0ck commented 2 years ago

It would be really nice to get this fixed :smile:

Broken on Pop!_OS as well, with the same issue as jonano. (No need to install libssl-dev for me though)

eggplants commented 2 years ago
#!/usr/bin/env bash

set -ex

cd /tmp
wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/openssl/1.1.1l-1ubuntu1.3/openssl_1.1.1l.orig.tar.gz
tar -xvf openssl_1.1.1l.orig.tar.gz
sudo apt install libssl-dev liblzo2-dev libpam0g-dev -y
cd openssl_1.1.1l/
./config shared enable-ec_nistp_64_gcc_128 -Wl,-rpath=/usr/local/ssl/lib --prefix=/usr/local/ssl
make -j 4
sudo make install
sudo ln -s /usr/local/ssl/bin/openssl /usr/local/bin/openssl
echo $'append your .*rc, .*profile, or .*env:\n\nexport LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/ssl/lib"'