0

My installation of R seems to be faulty. I tried using several packages using library(), and was told they could not be found. I then tried just running library() with no arguments, and it said Warning message: In library() : library ‘/usr/local/lib/R/site-library’ contains no packages. The output of .libpaths is

[1] "/home/username/R/x86_64-pc-linux-gnu-library/3.2"
[2] "/usr/local/lib/R/site-library"                       
[3] "/usr/lib/R/site-library"                             
[4] "/usr/lib/R/library"

The output of sessionInfo() is

R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.3

locale:
 [1] LC_CTYPE=en_AU.UTF-8      
 [2] LC_NUMERIC=C              
 [3] LC_TIME=en_AU.UTF-8       
 [4] LC_COLLATE=en_AU.UTF-8    
 [5] LC_MONETARY=en_AU.UTF-8   
 [6] LC_MESSAGES=en_AU.UTF-8   
 [7] LC_PAPER=en_AU.UTF-8      
 [8] LC_NAME=C                 
 [9] LC_ADDRESS=C              
[10] LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_AU.UTF-8
[12] LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

loaded via a namespace (and not attached):
[1] tools_3.2.3

I have not been able to find any information on this error online. Everyone else seems to have a problem with not finding specific packages. I have not seen anyone complain about having no packages whatsoever.

These are the error messages I have received when attempting to install "tidyverse" from RStudio using install.packages("tidyverse"):

Installing package into ‘/home/username/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependencies

...

* installing *source* package ‘colorspace’ ...
** package ‘colorspace’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c colorspace.c -o colorspace.o
colorspace.c:2:19: fatal error: ctype.h: No such file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:159: recipe for target 'colorspace.o' failed
make: *** [colorspace.o] Error 1
ERROR: compilation failed for package ‘colorspace’
* removing ‘/home/dylanus-zwei/R/x86_64-pc-linux-gnu-library/3.4/colorspace’
Warning in install.packages :
  installation of package ‘colorspace’ had non-zero exit status

This repeats for a while, followed by:

Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-lcurl
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
 * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fedora, CentOS, RHEL)
 * csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.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=...'
--------------------------------------------------------------------

The same error arises for openssl. I installed libcurl this morning, so I'm not sure what it's expecting here.

checking for gcc... gcc -std=gnu99
checking whether the C compiler works... no

The C compiler definitely works. I have used it many times. The other messages all seem to be the same kind of thing.

  • Have you installed the packages you wish to use using `install.packages` ? – neilfws Mar 05 '18 at 10:38
  • @neilfws the base packages (which sessionInfo() says are attached) should still be in library regardless. library() showing up empty is really weird. – De Novo Mar 05 '18 at 10:44
  • What does `R.home()` return? – De Novo Mar 05 '18 at 10:45
  • I just tried running `install.packages(reshape2)` and it said `object 'reshape2' not found`. –  Mar 05 '18 at 10:48
  • R.home() returns "/usr/lib/R" –  Mar 05 '18 at 10:48
  • @Dylan_Oscar package name needs to be in quotes `install.packages("reshape2")` – neilfws Mar 05 '18 at 10:49
  • I just tried that, and it said installation had non-zero exit status. Calling the package with `library()` still doesn't work either. So something is going wrong with installing packages. –  Mar 05 '18 at 10:51
  • well, your .libpath is what it should be, at least. – De Novo Mar 05 '18 at 11:06
  • Weird. I might try uninstalling the whole thing and starting again tomorrow night. –  Mar 05 '18 at 11:16
  • @DanHall Not sure if you're able to help any further, but I have just tried uninstalling and reinstalling R with no success. I just downloaded a whole bunch of packages and extracted them to `usr/local/lib/R/site-packages`, which is the directory that R is checking for packages, but it still says the directory contains no packages. Is there anything else I can try? –  Mar 06 '18 at 08:31
  • This might help: https://stackoverflow.com/questions/32540919/library-is-not-writable – De Novo Mar 07 '18 at 09:28

1 Answers1

1

This could be a similar problem, due to permissions: Library is not writable

What's the error message when you try installing packages? And what does the site-packages directory look like when you navigate to it using a shell? Is there anything in there? What are the permissions?

To summarize, we've now learned that the current permissions for the directory that is supposed to hold the packages are: drwxr_xr_x, if you copied the line for the correct directory (/usr/local/lib/R/site-library). I'm clarifying because it looks like you may have copy pasted the permissions for the first package in your site-directory, abind. If you did, then it means there are packages in site-directory and we have a different problem (possibly also a permissions problem, but read rather than write).

So if the output of ls -ld /usr/local/lib/R/site_library starts with drwxr-sr-x 6 root staff the answer, by Manual Va, from that question that should resolve things. It wouldn't hurt to add yourself to staff, in general, but that by itself won't solve your problem. Here's the modified answer for you

Do:

$ cd /usr/local/lib/R
$ sudo chmod go+w site-library
$ ls -l

The printed line should look like this:

drwxrwsrwx 2 root staff 0000 Mar 31 00:00 site-library
De Novo
  • 7,120
  • 1
  • 23
  • 39
  • I have been checking `/usr/local/lib/R/site-packages` as that is the directory R mentions when it searches. That directory was empty this morning. I unzipped a number of packages that I directly downloaded into that directory, but it is still empty according to R. –  Mar 07 '18 at 09:54
  • The output of `ls -l` is `drwxr-sr-x 6 root staff 4096 Mar 6 19:27 abind`. I have no idea what 's' in the permissions refers to, and I couldn't find any information in the man page for `ls`. Should I change permissions? I certainly don't want to change it to 777 if I can avoid that. I saw that the article you linked to also suggests adding myself to staff. That seems a bit elaborate, but I'll try that if you think that would fix it. –  Mar 07 '18 at 09:56
  • Actually I just tried installing "tidyverse" with Rstudio and it attempts to install in the R directory located in my home directory. There are some packages in that directory, but tidyverse is not there. I will update my question with the error messages. –  Mar 07 '18 at 10:01
  • I just tried moving all the packages I downloaded to `/usr/lib/R/site-library`, since that's the directory that comes up for `R.home()`, but calling `library()` still gave the message that it contains no packages. –  Mar 07 '18 at 10:29
  • Yeah, don't put them in R.home(). They need to be in a subdirectory. Different installations expect different names for that subdirectory. So R says it's empty, but you see the packages in there – De Novo Mar 07 '18 at 21:05
  • given your current permissions for site-packages, you need to change them. It's set up now so that root permissions are necessary to write to the directory. Change the permissions as described in that first answer, then also add yourself to group. – De Novo Mar 07 '18 at 21:20
  • also `s` means sticky. Here it allows anyone that writes to the directory to be added to the group for the entire directory. That's good. – De Novo Mar 07 '18 at 21:22
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/166425/discussion-between-dan-hall-and-dylan-oscar). – De Novo Mar 07 '18 at 21:28