Search code examples
rubuntuubuntu-18.04libsodiumsodium

Problem installing Sodium package in R on an Ubuntu system


I am trying to install a package called sodium in R on an Ubuntu system but I'm getting an error message like the following:

install.packages("sodium", dependencies = T)

...

* installing *source* package ‘sodium’ ...
** package ‘sodium’ successfully unpacked and MD5 sums checked
Package libsodium was not found in the pkg-config search path.
Perhaps you should add the directory containing `libsodium.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libsodium' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lsodium
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libsodium was not found. Try installing:
 * deb: libsodium-dev (Debian, Ubuntu, etc)
 * rpm: libsodium-devel (Fedora, EPEL)
 * csw: libsodium_dev (Solaris)
 * brew: libsodium (OSX)
If libsodium is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libsodium.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘sodium’
* removing ‘/R/x86_64-pc-linux-gnu-library/3.4/sodium’
Warning in install.packages :
  installation of package ‘sodium’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmph70q7Q/downloaded_packages’

The following code didn't install it either.

install.packages("libsodium-dev", dependencies = T)

Warning in install.packages :
  package ‘libsodium-dev’ is not available (for R version 3.4.4)

I also tried install_github but still get an error:

devtools::install_github("jedisct1/libsodium")

Error: Failed to install 'unknown package' from GitHub:
  Timeout was reached: [api.github.com] Resolving timed out after 10000 milliseconds

Any idea on how to install this package?

I wish installing packages on an Ubuntu R was as error free as doing it on Windows R. If someone could teach me how to avoid package installing errors in Ubuntu R, it'd be great.


Solution

  • You need to install libsodium-dev, some software for your computer that isn't necessarily R specific.

    You can do this via your terminal in linux. Go to your terminal and execute

    sudo apt install libsodium-dev

    Then go back to R and install the package with the usual command

    devtools::install_github("jedisct1/libsodium")