cannot install devtools!!! Please HELP

My lab has a Ubuntu version 20.04.4 LTS (Focal Fossa) and I have spent this past week trying to install devtools to no avail. I tried so many things but cannot seem to install it.

I even tried following these sudo tips among other tips but also failed.

I also tried conda but that also failed:
https://anaconda.org/conda-forge/r-devtools

Has anyone faced something similar and can help me please?

  • Can you recapitulate your error using the tutorial code and dataset? If so, provide a reproducible example.
if (!requireNamespace("devtools", quietly = TRUE)) install.packages("devtools")

I also tried all other options in the this link such as: r - Problems installing the devtools package - Stack Overflow

sudo apt-get install libcurl4-openssl-dev libssl-dev

which outputs the following:

sudo apt-get install libcurl4-openssl-dev libssl-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libcurl4-openssl-dev is already the newest version (7.68.0-1ubuntu2.12).
libssl-dev is already the newest version (1.1.1f-1ubuntu2.16).
0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.

Did you post your log file? If not, add it now.
added below

if (!requireNamespace("devtools", quietly = TRUE)) install.packages("devtools")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
also installing the dependencies ‘zip’, ‘gert’, ‘usethis’

trying URL https://cloud.r-project.org/src/contrib/zip_2.2.0.tar.gz
Content type 'application/x-gzip' length 114391 bytes (111 KB)
downloaded 111 KB

trying URL https://cloud.r-project.org/src/contrib/gert_1.7.0.tar.gz
Content type 'application/x-gzip' length 118288 bytes (115 KB)
downloaded 115 KB

trying URL https://cloud.r-project.org/src/contrib/usethis_2.1.6.tar.gz
Content type 'application/x-gzip' length 342349 bytes (334 KB)
downloaded 334 KB

trying URL 'https://cloud.r-project.org/src/contrib/devtools_2.4.4.tar.gz'
Content type 'application/x-gzip' length 374492 bytes (365 KB)
downloaded 365 KB

ERROR: failed to lock directory ‘/usr/local/lib/R/site-library’ for modifying
Try removing ‘/usr/local/lib/R/site-library/00LOCK-zip’
ERROR: dependency ‘zip’ is not available for package ‘gert’

removing ‘/usr/local/lib/R/site-library/gert’
ERROR: dependency ‘gert’ is not available for package ‘usethis’
removing ‘/usr/local/lib/R/site-library/usethis’
ERROR: dependency ‘usethis’ is not available for package ‘devtools’
removing ‘/usr/local/lib/R/site-library/devtools’
The downloaded source packages are in
‘/tmp/Rtmp8Of1D0/downloaded_packages’
Warning messages:
1: In install.packages("devtools") :
installation of package ‘zip’ had non-zero exit status
2: In install.packages("devtools") :
installation of package ‘gert’ had non-zero exit status
3: In install.packages("devtools") :
installation of package ‘usethis’ had non-zero exit status
4: In install.packages("devtools") :
installation of package ‘devtools’ had non-zero exit status

The error messages gives you some information:

ERROR: failed to lock directory ‘/usr/local/lib/R/site-library’ for modifying
Try removing ‘/usr/local/lib/R/site-library/00LOCK-zip’

Try deleting this lockfile, then install.packages("zip") and see what happens.

There might be multiple packages that you need to install first. When this happens again, try to read the error messages carefull, and from the bottom up, resolve these one-by-one, and this should help.

PS. I noticed that you are trying to install to a site library (/usr/local/lib/R/site-library), not a user library. The problem here might be that you are on a shared machine, and don't have permissions to install to the site library.

Please run this in R and report the results:

.libPaths()
Sys.getenv("R_LIBS_USER")

Good luck.

1 Like

@andrie Thanks for the suggestions. I was able to finally install devtools. But I am having a crazy hard time trying to install other packages like "Signac" and "Seurat" among others. I even try to install the dependecies one by one like a crazy person and still doesn't work. Why am I facing such problems?

Installing package into ‘/home/afarha5/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
also installing the dependencies ‘rgeos’, ‘igraph’, ‘leiden’, ‘SeuratObject’

trying URL 'https://cloud.r-project.org/src/contrib/rgeos_0.5-9.tar.gz'
Content type 'application/x-gzip' length 290240 bytes (283 KB)
==================================================
downloaded 283 KB

trying URL 'https://cloud.r-project.org/src/contrib/igraph_1.3.4.tar.gz'
Content type 'application/x-gzip' length 2494877 bytes (2.4 MB)
==================================================
downloaded 2.4 MB

trying URL 'https://cloud.r-project.org/src/contrib/leiden_0.4.2.tar.gz'
Content type 'application/x-gzip' length 2946844 bytes (2.8 MB)
==================================================
downloaded 2.8 MB

trying URL 'https://cloud.r-project.org/src/contrib/SeuratObject_4.1.0.tar.gz'
Content type 'application/x-gzip' length 188875 bytes (184 KB)
==================================================
downloaded 184 KB

trying URL 'https://cloud.r-project.org/src/contrib/Seurat_4.1.1.tar.gz'
Content type 'application/x-gzip' length 1427419 bytes (1.4 MB)
==================================================
downloaded 1.4 MB

* installing *source* package ‘rgeos’ ...
** package ‘rgeos’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc
configure: CXX: g++ -std=gnu++14
configure: rgeos: 0.5-9
checking for /usr/bin/svnversion... no
configure: svn revision: 684
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/home/afarha5/R/x86_64-pc-linux-gnu-library/4.2/rgeos’
* installing *source* package ‘igraph’ ...
** package ‘igraph’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether the compiler supports GNU C++... yes
checking whether g++ -std=gnu++11 accepts -g... yes
checking for g++ -std=gnu++11 option to enable C++11 features... none needed
checking whether the compiler supports GNU Fortran... yes
checking whether gfortran accepts -g... yes
checking for expm1... yes
checking for fmin... yes
checking for finite... yes
checking for log2... yes
checking for log1p... yes
checking for rint... yes
checking for rintf... yes
checking for round... yes
checking for stpcpy... yes
checking for strcasecmp... yes
checking for _stricmp... no
checking for strdup... yes
checking for isfinite... no
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for sys/times.h... yes
checking for net/if.h... yes
checking for netinet/in.h... yes
checking for net/if_dl.h... no
checking for sys/sockio.h... no
checking for sys/un.h... yes
checking for sys/socket.h... yes
checking for sys/ioctl.h... yes
checking for sys/time.h... yes
checking for sys/file.h... yes
checking for struct sockaddr.sa_len... no
checking for xml2-config... /home/afarha5/anaconda3/bin/xml2-config
checking for xmlSAXUserParseFile in -lxml2... yes
checking for libxml/parser.h... yes
checking for __gmpz_add in -lgmp... no
checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for glp_read_mps in -lglpk... no
configure: creating ./config.status
config.status: creating src/Makevars.tmp
config.status: creating src/Makevars
config.status: creating src/config.h

*** Compiler settings used:
    CC=gcc
    LD=
    CFLAGS=-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
    CPPFLAGS=
    CXX=g++ -std=gnu++11
    CXXFLAGS=-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
    LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro
    LIBS=
** libs
..................
..................
..................
..................
..................
...............
installing to /home/afarha5/R/x86_64-pc-linux-gnu-library/4.2/00LOCK-igraph/00new/igraph/libs
** R
** demo
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/afarha5/R/x86_64-pc-linux-gnu-library/4.2/00LOCK-igraph/00new/igraph/libs/igraph.so':
  libgfortran.so.4: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/afarha5/R/x86_64-pc-linux-gnu-library/4.2/igraph’
ERROR: dependency ‘igraph’ is not available for package ‘leiden’
* removing ‘/home/afarha5/R/x86_64-pc-linux-gnu-library/4.2/leiden’
ERROR: dependency ‘rgeos’ is not available for package ‘SeuratObject’
* removing ‘/home/afarha5/R/x86_64-pc-linux-gnu-library/4.2/SeuratObject’
ERROR: dependencies ‘igraph’, ‘leiden’, ‘SeuratObject’ are not available for package ‘Seurat’
* removing ‘/home/afarha5/R/x86_64-pc-linux-gnu-library/4.2/Seurat’

The downloaded source packages are in
        ‘/tmp/RtmpfG2oiq/downloaded_packages’
Warning messages:
1: In install.packages("Seurat") :
  installation of package ‘rgeos’ had non-zero exit status
2: In install.packages("Seurat") :
  installation of package ‘igraph’ had non-zero exit status
3: In install.packages("Seurat") :
  installation of package ‘leiden’ had non-zero exit status
4: In install.packages("Seurat") :
  installation of package ‘SeuratObject’ had non-zero exit status
5: In install.packages("Seurat") :
  installation of package ‘Seurat’ had non-zero exit status
> library(Seurat)
Error in library(Seurat) : there is no package called ‘Seurat’
> library("Seurat")
Error in library("Seurat") : there is no package called ‘Seurat’

Keep reading the error messages. In your logs you have this:

This most likely means that you are missing a system dependency on your linux machine. The system dependencies are usually documented in the package DESCRIPTION file, and the easiest way to determine these is to look for the system dependencies at https://packagemanager.rstudio.com/

In the case of rgeos, see Posit Package Manager

Look for this information:

INSTALL SYSTEM PREREQUISITES ON UBUNTU 20.04 (FOCAL)
apt-get install -y libgeos-dev

Do this for libgeos-dev.

Rinse and repeat for all your packages.

FWIW, it's notoriously hard to install geospatial packages on Linux. You have several system dependencies to install.

Good luck.

@andrie Unfortunately that does not solve it. I may be facing a bigger problem here.
For example, I am trying to install the package Seurat. I get an error saying it needs a package called igraph. I install igraph with all it system dependencies and then face such an error (see below). I do not know why it is so hard to install R packages.

installing to /home/afarha5/R/x86_64-pc-linux-gnu-library/4.2/00LOCK-igraph/00new/igraph/libs
** R
** demo
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/afarha5/R/x86_64-pc-linux-gnu-library/4.2/00LOCK-igraph/00new/igraph/libs/igraph.so':
libgfortran.so.4: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed

  • removing ‘/home/afarha5/R/x86_64-pc-linux-gnu-library/4.2/igraph’

Actually this solved it. Apparently Anaconda3 has been interfering with things.

I just had the same problem installing igraph in Ubuntu 16.04 on R 3.5.2. I can confirm that this issue is due to the package installer trying to use the shared object library for libgfortran in Anaconda3 when compiling the igraph package.

A very quick and dirty work around for this is to temporarily break your Anaconda installation by moving it to a .bak folder, install igraph in R, and then move Anaconda back to its original directory name.

$ whereis anaconda
$ anaconda: /opt/anaconda3/bin/anaconda
$ # adjust the next line based on the output from the whereis command
$ # sudo mv /opt/anaconda3/ /opt/anaconda3.bak
$ R
> install.packages("igraph")
> q()
> n
$ # again, adjust the next line based on the output from the whereis command
$ # sudo mv /opt/anaconda3.bak/ /opt/anaconda3

Now if you load igraph with library(igraph) it should work and Anaconda will too.

NB: You do not need sudo in the above command if you have Anaconda installed in your home directory.