jeroen / openssl

OpenSSL bindings for R
Other
63 stars 19 forks source link

Installation error on Ubuntu 20.04 #102

Closed Robinlovelace closed 2 years ago

Robinlovelace commented 2 years ago

Not sure what's causing this and may not be reproducible but this is what I'm seeing on my desktop, reporting in case of use/interest:

> install.packages("openssl")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/openssl_2.0.1.tar.gz'
Content type 'application/x-gzip' length 1204569 bytes (1.1 MB)
==================================================
downloaded 1.1 MB

* installing *source* package ‘openssl’ ...
** package ‘openssl’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-l:libssl.so.3 -l:libcrypto.so.3
** libs
rm -f aes.o base64.o bignum.o cert.o compatibility.o diffie.o envelope.o error.o hash.o info.o keygen.o keys.o onload.o openssh.o password.o pbkdf.o pem.o pkcs12.o pkcs7.o rand.o rsa.o signing.o ssl.o stream.o write.o x25519.o openssl.so bcrypt/libstatbcrypt.a bcrypt/bcrypt_pbkdf.o bcrypt/blowfish.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c aes.c -o aes.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c base64.c -o base64.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c bignum.c -o bignum.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c cert.c -o cert.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c compatibility.c -o compatibility.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c diffie.c -o diffie.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c envelope.c -o envelope.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c error.c -o error.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c hash.c -o hash.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c info.c -o info.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c keygen.c -o keygen.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c keys.c -o keys.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c onload.c -o onload.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c openssh.c -o openssh.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c password.c -o password.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c pbkdf.c -o pbkdf.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c pem.c -o pem.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c pkcs12.c -o pkcs12.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c pkcs7.c -o pkcs7.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c rand.c -o rand.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c rsa.c -o rsa.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c signing.c -o signing.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c ssl.c -o ssl.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c stream.c -o stream.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c write.c -o write.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c x25519.c -o x25519.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c bcrypt/bcrypt_pbkdf.c -o bcrypt/bcrypt_pbkdf.o
gcc -I"/usr/share/R/include" -DNDEBUG -DOPENSSL_SUPPRESS_DEPRECATED     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-apO4Ea/r-base-4.2.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c bcrypt/blowfish.c -o bcrypt/blowfish.o
ar rcs bcrypt/libstatbcrypt.a bcrypt/bcrypt_pbkdf.o bcrypt/blowfish.o
gcc -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o openssl.so aes.o base64.o bignum.o cert.o compatibility.o diffie.o envelope.o error.o hash.o info.o keygen.o keys.o onload.o openssh.o password.o pbkdf.o pem.o pkcs12.o pkcs7.o rand.o rsa.o signing.o ssl.o stream.o write.o x25519.o -Lbcrypt -lstatbcrypt -l:libssl.so.3 -l:libcrypto.so.3 -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/00LOCK-openssl/00new/openssl/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘openssl’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/usr/local/lib/R/site-library/00LOCK-openssl/00new/openssl/libs/openssl.so':
  libssl.so.3: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/openssl’
* restoring previous ‘/usr/local/lib/R/site-library/openssl’
Warning in install.packages :
  installation of package ‘openssl’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmp0z40sC/downloaded_packages’
jeroen commented 2 years ago

This looks like a broken libssl on your machine. Did you manually upgrade this server from 18.04 to 20.04 maybe?

Try forcing a reinstall of libssl:

sudo apt-get install --reinstall libssl-dev libssl3

Robinlovelace commented 2 years ago

Did you manually upgrade this server from 18.04 to 20.04 maybe?

No but may have tried to make libssl.so.3 available in different places, there's an issue in rstudio/rstudio on that I can dig out if useful. In any case, libssl3 appears to not exist in standard 20.04 repos and reinstalling libssl-dev does not solve the problem.

``` sudo apt-get install --reinstall libssl-dev libssl3 [sudo] password for robin: Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package libssl3 ~/github/udsleeds took 7s ➜ sudo apt-get install libssl-dev libssl3 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package libssl3 ~/github/udsleeds ➜ sudo apt-get install --reinstall libssl-dev Reading package lists... Done Building dependency tree Reading state information... Done 0 to upgrade, 0 to newly install, 1 reinstalled, 0 to remove and 0 not to upgrade. Need to get 1,584 kB of archives. After this operation, 0 B of additional disk space will be used. Get:1 http://gb.archive.ubuntu.com/ubuntu focal-updates/main amd64 libssl-dev amd64 1.1.1f-1ubuntu2.13 [1,584 kB] Fetched 1,584 kB in 0s (7,442 kB/s) (Reading database ... 606536 files and directories currently installed.) Preparing to unpack .../libssl-dev_1.1.1f-1ubuntu2.13_amd64.deb ... Unpacking libssl-dev:amd64 (1.1.1f-1ubuntu2.13) over (1.1.1f-1ubuntu2.13) ... Setting up libssl-dev:amd64 (1.1.1f-1ubuntu2.13) ... R Error: package or namespace load failed for ‘openssl’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/usr/local/lib/R/site-library/00LOCK-openssl/00new/openssl/libs/openssl.so': libssl.so.3: cannot open shared object file: No such file or directory Error: loading failed Execution halted ERROR: loading failed * removing ‘/usr/local/lib/R/site-library/openssl’ * restoring previous ‘/usr/local/lib/R/site-library/openssl’ Warning in install.packages : installation of package ‘openssl’ had non-zero exit status The downloaded source packages are in ‘/tmp/RtmpDaHKZU/downloaded_packages’ ```
jeroen commented 2 years ago

Wait how did you end up with libssl3 in ubuntu 20.04? That version of libssl was introduced in ubuntu 22.04.

Can you check if you have a (second) copy of libssl in /usr/local/include/openssl? The only libssl on your machine should be in /usr/include/openssl

Robinlovelace commented 2 years ago

Yes, there it is:

ls /usr/local/include/openssl                                         
aes.h       bnerr.h      cmserr.h         core.h              decodererr.h  ecdsa.h       ess.h         kdf.h         obj_mac.h      pem.h        rc2.h        srp.h            symhacks.h  x509err.h
asn1err.h   bn.h         cms.h            core_names.h        decoder.h     ecerr.h       evperr.h      lhash.h       ocsperr.h      pkcs12err.h  rc4.h        srtp.h           tls1.h      x509.h
asn1.h      buffererr.h  comperr.h        core_object.h       des.h         ec.h          evp.h         macros.h      ocsp.h         pkcs12.h     rc5.h        ssl2.h           trace.h     x509v3err.h
asn1_mac.h  buffer.h     comp.h           crmferr.h           dherr.h       encodererr.h  fipskey.h     md2.h         opensslconf.h  pkcs7err.h   ripemd.h     ssl3.h           tserr.h     x509v3.h
asn1t.h     camellia.h   conf_api.h       crmf.h              dh.h          encoder.h     fips_names.h  md4.h         opensslv.h     pkcs7.h      rsaerr.h     sslerr.h         ts.h        x509_vfy.h
asyncerr.h  cast.h       conferr.h        cryptoerr.h         dsaerr.h      engineerr.h   hmac.h        md5.h         ossl_typ.h     proverr.h    rsa.h        sslerr_legacy.h  txt_db.h
async.h     cmac.h       conf.h           cryptoerr_legacy.h  dsa.h         engine.h      httperr.h     mdc2.h        param_build.h  provider.h   safestack.h  ssl.h            types.h
bioerr.h    cmperr.h     configuration.h  crypto.h            dtls1.h       e_os2.h       http.h        modes.h       params.h       prov_ssl.h   seed.h       stack.h          uierr.h
bio.h       cmp.h        conftypes.h      cterr.h             ebcdic.h      err.h         idea.h        objectserr.h  pem2.h         randerr.h    self_test.h  storeerr.h       ui.h
blowfish.h  cmp_util.h   core_dispatch.h  ct.h                ecdh.h        esserr.h      kdferr.h      objects.h     pemerr.h       rand.h       sha.h        store.h          whrlpool.h
jeroen commented 2 years ago

Did you attempt to install libssl from source? There should be no libssl in /usr/local, only in /usr/include and /usr/lib. Try removing it:

sudo rm -Rf /usr/local/include/openssl
sudo rm -f /usr/local/lib/libssl.*
sudo rm -f /usr/local/lib/libcrypto.*

Then it should work.

Robinlovelace commented 2 years ago
sudo rm -Rvf /usr/local/include/openssl

After that it works! Many thanks Jeroen.

Robinlovelace commented 2 years ago

Did you attempt to install libssl from source?

Yes that was probably the underlying cause.