Can't install github package in RStudio: "Permission denied" - r

I wanted to run some code that uses the 'rethinking' library. As instructed there, I first installed rstan, which went fine, then typed
install_github("rmcelreath/rethinking")
The latter gives the errors:
Error: package or namespace load failed for 'ggplot2' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace 'ellipsis' 0.3.1 is being loaded, but >= 0.3.2 is required
Error: package 'ggplot2' could not be loaded
In addition: Warning messages:
1: package 'rstan' was built under R version 4.0.5
2: package 'StanHeaders' was built under R version 4.0.5
3: package 'ggplot2' was built under R version 4.0.5
Execution halted
ERROR: lazy loading failed for package 'rethinking'
* removing 'C:/Program Files/R/R-4.0.3/library/rethinking'
Warning messages:
1: In file.copy(savedcopy, lib, recursive = TRUE) :
problem copying C:\Program Files\R\R-4.0.3\library\00LOCK\curl\libs\x64\curl.dll to C:\Program Files\R\R-4.0.3\library\curl\libs\x64\curl.dll: Permission denied
2: In file.copy(savedcopy, lib, recursive = TRUE) :
problem copying C:\Program Files\R\R-4.0.3\library\00LOCK\ps\libs\x64\ps.dll to C:\Program Files\R\R-4.0.3\library\ps\libs\x64\ps.dll: Permission denied
3: In file.copy(savedcopy, lib, recursive = TRUE) :
problem copying C:\Program Files\R\R-4.0.3\library\00LOCK\ellipsis\libs\x64\ellipsis.dll to C:\Program Files\R\R-4.0.3\library\ellipsis\libs\x64\ellipsis.dll: Permission denied
4: In file.copy(savedcopy, lib, recursive = TRUE) :
problem copying C:\Program Files\R\R-4.0.3\library\00LOCK\digest\libs\x64\digest.dll to C:\Program Files\R\R-4.0.3\library\digest\libs\x64\digest.dll: Permission denied
5: In i.p(...) :
installation of package ‘C:/Users/User/AppData/Local/Temp/RtmpAfQQaY/file1268133e3024/rethinking_2.13.tar.gz’ had non-zero exit status
> source("~/.active-rstudio-document", echo=TRUE)
Indeed, if I try to run code from the library, I get:
> library(rethinking)
Error in library(rethinking) : there is no package called ‘rethinking’
I am running Rstudio 2021.09.0 as administrator, on Windows 10.
I also tried installing the library from the Packages|Install button, but that gives
> install.packages("rethinking")
Warning in install.packages :
package ‘rethinking’ is not available for this version of R
The solutions suggested here did not work for me. Any help would be appreciated!
EDIT: for solution, please see comments - thanks for the replies!

Related

ERROR: lazy loading failed for package ‘omd’

In this question How to install.packages of R 4.2.0?, when I try the code in R
install.packages("devtools")
library("devtools")
install_github("sangwon-hyun/omd", subdir = "omd")
I have tried install goal as the comment on R
install.packages(c('rasterVis', 'rgdal', 'raster', 'sp', 'sf', 'gstat'))
But it still shows that
ERROR: lazy loading failed for package ‘omd’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library/omd’
Warning message:
In i.p(...) :
installation of package ‘/var/folders/4v/wwrgppgn1s5dqn1mfv457mqm0000gn/T//RtmpJAqJio/fileafc37eeacc4a/omd_0.0.0.9000.tar.gz’ had non-zero exit status

RShiny installation ERROR: lazy loading failed for package 'shiny'

I am trying to install the Shiny package, and I am getting this error
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'httpuv' 1.4.1 is being loaded, but >= 1.4.4 is required
ERROR: lazy loading failed for package 'shiny'
* removing 'C:/Users/ikum/Documents/R/win-library/3.3/shiny'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\ikum\Documents\R\win-library\3.3" C:\Users\ikum\AppData\Local\Temp\RtmpcbANIA/downloaded_packages/shiny_1.2.0.tar.gz' had status 1
Warning in install.packages :
installation of package ‘shiny’ had non-zero exit status
Even when I try to download the latest version of httpuv using the targz file, it is still going to the 1.4.1 version. I deleted httpuv as well and reinstalled it manually as well as from the CRAN repository. Nothing seems to be working.
I also have the latest version or RStudio and R.
Is there a solution to this?
You can try to add type = "binary" argument:
install.packages("shiny", type ="binary")

Installing odbc package

I am trying to use the new RStudio Connection Pane to set up an ODBC connection. When I try to do this I get the error message:
Required package versions could not be found: odbc 1.1.1 is required but 1.0.1 is available
I have tried installing the latest odbc package by running:
devtools::install_github("r-dbi/odbc")
It runs for quite some time but not until the end. The last part of the log is:
Warning in file.copy(files, dest, overwrite = TRUE) : problem
copying .\odbc.dll to
C:\Users\Daniel.Thuresson\Documents\R\win-library\3.3\odbc\libs\x64\odbc.dll:
Permission denied
** R
** inst
** tests
** byte-compile and prepare package for lazy loading Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck =
vI[[j]]) : there is no package called 'bit'
ERROR: lazy loading failed for package 'odbc'
* removing 'C:/Users/Daniel.Thuresson/Documents/R/win-library/3.3/odbc'
* restoring previous 'C:/Users/Daniel.Thuresson/Documents/R/win-library/3.3/odbc'
Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date
= TRUE) : problem copying C:\Users\Daniel.Thuresson\Documents\R\win-library\3.3\00LOCK-r-dbi-odbc-b3d159a\odbc\libs\x64\odbc.dll
to
C:\Users\Daniel.Thuresson\Documents\R\win-library\3.3\odbc\libs\x64\odbc.dll:
Permission denied
Error: Command failed (1)
In addition: Warning messages:
1: In value[3L] : object 'odbcListDrivers' not found
2: In value[3L] : object 'odbcListDrivers' not found
3: In value[3L] : object 'odbcListDrivers' not found
I am a noob when it comes to this. I have only used R for analyzing local data and never have had to connect to a database. I would very much appreciate if someone could help me solve this!

Warning in install.packages : installation of package ‘igraph’ had non-zero exit status

I want to install phyloseq from BioConductor. When I do so, and try to load it, I get an error about igraph (even though I set dependencies to be TRUE). I have tried installing igraph independently, and that is also not working, with non-zero exit status.
I am using RStudio
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Does anyone have any advice? Errors are pasted below.
Thank you for your help!
Here is my command:
install.packages("phyloseq", dependencies = TRUE)
Here is the warning:
Warning in install.packages :
dependency ‘igraph’ is not available
Here I try to load the package I want: library("phyloseq")
Here is the warning: Error:
package or namespace load failed for ‘phyloseq’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]). there is no package called ‘igraph’
Here I try to install igraph directly: install.packages("igraph", dependencies = TRUE)
Here is the compilation failure:
ERROR: compilation failed for package ‘graph’ Warning in install.packages : installation of package ‘igraph’ had non-zero exit status
Open a new terminal and type:
xcode-select --install
I went to the developer page of igraph and downloaded the package into my r library folder. For whatever reason, r does not pull igraph into the library folder when called on the command line so you have to do it manually. Shout out to my prof who showed me how to do this.

Build R package on Mac for Windows

I develop a package under Mac and want to distribute it to my colleagues. I can build the package under Mac and can install it under Mac and 'most' of my colleagues Windows PCs. Some of these are Windows 7 and some are Windows 8. All of them use RStudio and different R Versions all above 3.1.
I have now one big Problem with one computer and can not figure out what to do.
When I try to install the package, I get the following message
install.packages("C:/Users/ncasasvi/Downloads/imbproteomicsr_0.1.6.tar.gz", repos = NULL, type = "source", lib="\\fs02/ncasasvi$/Dokumente/R/R-3.1.2/library")
Warning in install.packages :
'lib = "\fs02/ncasasvi$/Dokumente/R/R-3.1.2/library"' is not writable
'\\fs02\ncasasvi$\Dokumente'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
'\\fs02\ncasasvi$\DOKUME~1\R\R-31~1.2' is not recognized as an internal or external command,
operable program or batch file.
Warning in install.packages :
running command '"//fs02/ncasasvi$/DOKUME~1/R/R-31~1.2/bin/x64/R" CMD INSTALL -l "\\fs02\ncasasvi$\Dokumente\R\win-library\3.1" "C:/Users/ncasasvi/Downloads/imbproteomicsr_0.1.6.tar.gz"' had status 1
Warning in install.packages :
installation of package 'C:/Users/ncasasvi/Downloads/imbproteomicsr_0.1.6.tar.gz' had non-zero exit status
I copied now the complete package source, so all folders and files, to a Windows machine, installed Rtools and devtools there and build the package on the windows machine with the same problem...
Is there a way to geht a more precise error message, not just status one? I have no further Ideas.
I also sensed my file to win builder. It reported no error messages, but I also didn't got a 'new build package' from the website.
Hope some of you have some suggestions. Thanks in advance!
EDIT:
After changing the path to something without \\ at the beginning and trying to get rid of all the other error messages, I got this message:
> install.packages("C:/Users/ncasasvi/Downloads/imbproteomicsr_latest.tar.gz", repos = NULL, type = "source", lib=('U:/Dokumente/R/win-library/'))
Error: ERROR: no packages specified
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-31~1.2/bin/x64/R" CMD INSTALL -l "U:\Dokumente\R\win-library\" "C:/Users/ncasasvi/Downloads/imbproteomicsr_latest.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘C:/Users/ncasasvi/Downloads/imbproteomicsr_latest.tar.gz’ had non-zero exit status
In between, I had a partly success, but it still could not install the package. This was the output in between:
> install.packages("C:/Users/ncasasvi/Downloads/imbproteomicsr_latest (2).tar.gz", repos = NULL, type = "source")
Installing package into ‘\\fs02/ncasasvi$/Dokumente/R/win-library/3.1’
(as ‘lib’ is unspecified)
'\\fs02\ncasasvi$\Dokumente'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
* installing *source* package 'imbproteomicsr' ...
** R
** data
*** moving datasets to lazyload DB
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Warning in library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE) :
no library trees found in 'lib.loc'
Error: loading failed
Execution halted
*** arch - x64
Warning in library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE) :
no library trees found in 'lib.loc'
Error: loading failed
Execution halted
ERROR: loading failed for 'i386', 'x64'
* removing '\\fs02/ncasasvi$/Dokumente/R/win-library/3.1/imbproteomicsr'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-31~1.2/bin/x64/R" CMD INSTALL -l "\\fs02\ncasasvi$\Dokumente\R\win-library\3.1" "C:/Users/ncasasvi/DOWNLO~1/imbproteomicsr_latest (2).tar.gz"' had status 1
Warning in install.packages :
installation of package ‘C:/Users/ncasasvi/DOWNLO~1/imbproteomicsr_latest (2).tar.gz’ had non-zero exit status

Resources