Ubuntu – Unable to install R packages in Ubuntu 18.04

18.04curlpackage-managementrshared library

Issue

Unable to install a few R packages (statistical programming language) since updating from 16.04 to Ubuntu 18.04.
The problem is related to the use of the shared library libcurl. More precisely:

/usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not    
found (required by /home/avila/R/x86_64-pc-linux-gnu-library/3.4/curl
/libs/curl.so)

sofar, I tried…

  • … to install a previous version of libcurl with
    sudo apt-get install libcurl3, but other libraries were uninstalled on the procedure and R was not usable.

error output

When trying to install package called "forecast", for example:

install.packages("forecast")
 installing to /home/avila/R/x86_64-pc-linux-gnu-library/3.4/forecast/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :  unable to load shared
object '/home/avila/R/x86_64-pc-linux-gnu-library/3.4/curl/libs/curl.so':
/usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not    
found (required by /home/avila/R/x86_64-pc-linux-gnu-library/3.4/curl
/libs/curl.so)

ERROR: lazy loading failed for package ‘forecast’
* removing ‘/home/avila/R/x86_64-pc-linux-gnu-library/3.4/forecast’
Warning in install.packages :
installation of package ‘forecast’ had non-zero exit status

other info:

  • R version 3.4.4 (2018-03-15)
  • Platform: x86_64-pc-linux-gnu (64-bit)

Best Answer

It seems that to get predictive results you may want to start with renaming your existing R personal library with:

mv /home/$USER/R /home/$USER/R_old

Also install development package of curl:

sudo apt-get install libcurl4-openssl-dev

And then try to install your R-package from R-terminal:

$ R
install.packages("forecast")