Get Permission denied Errors When Installing Packages in RStudio

I installed R 4.1.3 and RStudio-Server 2.22.12.0 on a Linux (RHEL 8.7) server. I am able to access RStudio without any problems, however, I am getting the following errors when trying to install some packages. Note, I was able to download and install other packages so it's not that everything failed to install. The rstudio_tester user's home directory is fully accessible. I tried assigning all the permissions (777) to it but still getting the same errors. I am new to Linux and to RStudio. Please help. Thank you.

Below is an example.
install.packages("formattable")

I'm no expert but looking at the Installation manual I think the /tmp directory on your system is not executable. Try making a /tmp directory in your home directory and then setting the TMPDIR environment variable of R to that directory. To set the variable, use Sys.setenv()

Sys.setenv(TMPDIR="/path/to/your/new/tmp")
1 Like

Can you post the complete console output you get as formatted text? (screenshots are considered a bad practice here).

Here is how to do it :

Can you show the permissions for your package library?

ls - lah <<path to your package library >>

Please see below permission for my package library. All packages should be installed in the 4.1 directory

[rstudio_tester@********** 4.1]$ ls -lah /home/rstudio_tester/R/x86_64-pc-linux-gnu-library/
total 4.0K
drwxrwxrwx  3 rstudio_tester rstudio_tester   17 Feb 24 19:50 .
drwxrwxrwx  3 rstudio_tester rstudio_tester   41 Feb 24 19:50 ..
drwxrwxrwx 59 rstudio_tester rstudio_tester 4.0K Mar 10 03:44 4.1

Following are the packages that were installed successfully.

[rstudio_tester@********** ~]$ ls -lah /home/rstudio_tester/R/x86_64-pc-linux-gnu-library/4.1/
total 28K
drwxrwxrwx 59 rstudio_tester rstudio_tester 4.0K Mar 10 03:44 .
drwxrwxrwx  3 rstudio_tester rstudio_tester   17 Feb 24 19:50 ..
drwxrwxr-x  7 rstudio_tester rstudio_tester 4.0K Mar  9 18:08 askpass
drwxrwxrwx  7 rstudio_tester rstudio_tester  124 Mar  8 21:52 base64enc
drwxrwxr-x  6 rstudio_tester rstudio_tester 4.0K Mar  9 18:08 brew
drwxrwxr-x  7 rstudio_tester rstudio_tester  142 Mar  9 18:08 brio
drwxrwxrwx  7 rstudio_tester rstudio_tester  142 Mar  8 21:53 cachem
drwxrwxrwx 11 rstudio_tester rstudio_tester 4.0K Mar  8 21:52 cli
drwxrwxr-x  8 rstudio_tester rstudio_tester  141 Mar  9 18:08 clipr
drwxrwxr-x  7 rstudio_tester rstudio_tester  139 Mar  9 18:08 commonmark
drwxrwxr-x  8 rstudio_tester rstudio_tester  156 Mar  9 18:08 cpp11
drwxrwxr-x  6 rstudio_tester rstudio_tester  130 Mar  9 18:08 crayon
drwxrwxr-x  6 rstudio_tester rstudio_tester  146 Mar  9 18:09 desc
drwxrwxr-x 10 rstudio_tester rstudio_tester  181 Mar  9 18:09 diffobj
drwxrwxrwx 11 rstudio_tester rstudio_tester  179 Mar  8 21:52 digest
drwxrwxr-x  6 rstudio_tester rstudio_tester  146 Mar  9 18:09 downlit
drwxrwxrwx  7 rstudio_tester rstudio_tester  142 Mar  8 21:53 ellipsis
drwxrwxrwx  6 rstudio_tester rstudio_tester  130 Mar  8 21:53 evaluate
drwxrwxr-x  8 rstudio_tester rstudio_tester  138 Mar  9 18:08 fansi
drwxrwxrwx  7 rstudio_tester rstudio_tester  142 Mar  8 21:52 fastmap
drwxrwxr-x  8 rstudio_tester rstudio_tester  161 Mar  9 18:08 fontawesome
drwxrwxr-x  7 rstudio_tester rstudio_tester  141 Mar  9 18:08 gitcreds
drwxrwxrwx  8 rstudio_tester rstudio_tester  153 Mar  8 21:52 glue
drwxrwxrwx  7 rstudio_tester rstudio_tester  126 Mar  8 21:53 highr
drwxrwxrwx  8 rstudio_tester rstudio_tester  139 Mar  8 21:53 htmltools
drwxrwxr-x  6 rstudio_tester rstudio_tester  115 Mar  9 18:08 ini
drwxrwxrwx  7 rstudio_tester rstudio_tester  141 Mar  8 21:53 jquerylib
drwxrwxrwx  8 rstudio_tester rstudio_tester  166 Mar  8 21:52 jsonlite
drwxrwxrwx 14 rstudio_tester rstudio_tester 4.0K Mar  8 21:53 knitr
drwxrwxrwx  7 rstudio_tester rstudio_tester  141 Mar  8 21:53 lifecycle
drwxrwxrwx  8 rstudio_tester rstudio_tester 4.0K Mar  8 21:52 magrittr
drwxrwxrwx  6 rstudio_tester rstudio_tester  130 Mar  8 21:53 memoise
drwxrwxrwx  7 rstudio_tester rstudio_tester  127 Mar  8 21:52 mime
drwxrwxr-x  7 rstudio_tester rstudio_tester  157 Mar  9 18:09 pillar
drwxrwxr-x  6 rstudio_tester rstudio_tester  177 Mar  9 18:08 pkgconfig
drwxrwxr-x  6 rstudio_tester rstudio_tester  165 Mar  9 18:08 praise
drwxrwxr-x  6 rstudio_tester rstudio_tester  130 Mar  9 18:08 prettyunits
drwxrwxrwx  6 rstudio_tester rstudio_tester  130 Mar  8 21:52 R6
drwxrwxrwx  7 rstudio_tester rstudio_tester  142 Mar  8 21:52 rappdirs
drwxrwxr-x 16 rstudio_tester rstudio_tester 4.0K Mar  9 18:07 Rcpp
drwxrwxr-x  6 rstudio_tester rstudio_tester  130 Mar  9 18:09 rematch2
drwxrwxr-x  7 rstudio_tester rstudio_tester  191 Mar  9 18:08 remotes
drwxrwxrwx  7 rstudio_tester rstudio_tester  163 Mar  8 21:52 rlang
drwxrwxr-x  7 rstudio_tester rstudio_tester  157 Mar  9 18:08 rprojroot
drwxrwxr-x  8 rstudio_tester rstudio_tester  158 Mar  9 18:08 rstudioapi
drwxrwxr-x  6 rstudio_tester rstudio_tester  115 Mar  9 18:08 sessioninfo
drwxrwxr-x  8 rstudio_tester rstudio_tester  157 Mar  9 18:08 sourcetools
drwxrwxr-x  7 rstudio_tester rstudio_tester  171 Mar  9 18:07 sys
drwxrwxr-x  8 rstudio_tester rstudio_tester  153 Mar  9 18:09 tibble
drwxrwxrwx  6 rstudio_tester rstudio_tester  146 Mar  8 21:53 tinytex
drwxrwxr-x  8 rstudio_tester rstudio_tester  138 Mar  9 18:07 utf8
drwxrwxrwx  9 rstudio_tester rstudio_tester  184 Mar  8 21:53 vctrs
drwxrwxr-x  6 rstudio_tester rstudio_tester  130 Mar  9 18:09 waldo
drwxrwxr-x  8 rstudio_tester rstudio_tester  138 Mar  9 18:08 whisker
drwxrwxr-x  7 rstudio_tester rstudio_tester  141 Mar  9 18:08 withr
drwxrwxrwx  9 rstudio_tester rstudio_tester  168 Mar  8 21:53 xfun
drwxrwxr-x  8 rstudio_tester rstudio_tester  135 Mar  9 18:08 xtable
drwxrwxrwx  8 rstudio_tester rstudio_tester  190 Mar  8 21:53 yaml
drwxrwxr-x  8 rstudio_tester rstudio_tester  172 Mar  9 18:08 zip

This has resolved my issue. Thank you! I made a tmp directory in my home directory and then set the TMPDIR environment variable of R to that directory. After that, I was able to install the packages that failed to install. Now, I am trying to set up a new default package installation library so any new packages will be installed to that directory instead of the home one which there isn't much storage. I am assuming the tmp folder and the TMPDIR can also be pointing to another directory that's outside of the home one.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.