Permission denied when manually installing R package - r

Hi I am currently run R code with version 4.1.0 on ubuntu(WSL) right now. I try to install some R packages manually because my internet is too slow, but I cannot get permission, the warning messages suggest the probable reason "permission denied". Here is the error and warning messages.
Warning in dir.create(path, showWarnings = TRUE, recursive = TRUE, ...) :
cannot create dir 'Rhdf5lib_1.14.2/Rhdf5lib', reason 'Permission denied'
Error in mydir.create(name) :
failed to create directory ‘Rhdf5lib_1.14.2/Rhdf5lib’
I really hope someone can help me with this problem, thanks a lot!

Try to start your R session with sudo R. Other possible option is to specify a lib argument like install.packages("SomePackage", lib = "/home/user/R/...")

I try the following command
export PATH=$PATH: path/to/your/R
and run R directly,this works for me.

Related

Why does this error message show when I try to download a package?

I am currently trying to download a couple of packages via BiocManagerBiocManager::install("gplots")
But this error message shows up:
Error in unpackPkgZip(foundpkgs[okp, 2L], foundpkgs[okp, 1L], lib, libs_only, :
ERROR: failed to lock directory ‘C:\Users\Linap\AppData\Local\R\win-library\4.2’ for modifying
Try removing ‘C:\Users\Linap\AppData\Local\R\win-library\4.2/00LOCK’
Why does it say that and how do I fix the problem?
Thanks in advance!

Error in install_github: System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed

I was trying to install the package "pgenlibr" in the github, using the command
install_github("chrchang/plink-ng", subdir="/2.0/pgenlibr"), and received the error message.
> install_github("chrchang/plink-ng", subdir="/2.0/pgenlibr")
Downloading GitHub repo chrchang/plink-ng#HEAD
√ checking for file 'C:\Users\86137\AppData\Local\Temp\RtmpILEuSP\remotes109044a8685a\chrchang-plink-ng-73bdbc3\2.0\pgenlibr/DESCRIPTION' ...
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
problem copying .\pgenlibr\src\include to C:\Users\86137\AppData\Local\Temp\RtmpaONA8h\Rbuild2e1c6cc05dce\pgenlibr\src\include: Permission denied
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
problem copying .\pgenlibr\src\libdeflate to C:\Users\86137\AppData\Local\Temp\RtmpaONA8h\Rbuild2e1c6cc05dce\pgenlibr\src\libdeflate: Permission denied
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
problem copying .\pgenlibr\src\zstd to C:\Users\86137\AppData\Local\Temp\RtmpaONA8h\Rbuild2e1c6cc05dce\pgenlibr\src\zstd: Permission denied
ERROR
copying to build directory failed
Error: Failed to install 'pgenlibr' from GitHub:
System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed
I have installed its required software listed on Readme, Rtools, all packages dependencies. I have also tried other methods, delete all Rtmp files, run Rstudio as administrator, cancel "read only" to folder "temp" and "library" in the workpath, but gained no success.
In addition, I'm using Windows 10.
How can I solve this problem?
I have solve this problem on Ubuntu System.
There is a similar problem when installing 'cindex', Here is the a link.
So the reason seems to be that install_github( ) in Win10 can not deal with symlink very well.
I got the same error when I was building the source for an R package and there was a syntax error in the DESCRIPTION file.
To solve, I removed suspected culprits from the DESCRIPTION file and it worked, so then just narrowed down to isolate the offending line (it was a typo in the person() function in my case, but causes my vary).

Unable to run Papaja in Windows due to spaces in folder name

I'm trying to load papaja in R (version 3.6.0). I'm running Windows 10 on my computer. When I try to run devtools::install_github("crsh/papaja") I get the following error message:
package ‘markdown’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\My
Name\AppData\Local\Temp\RtmpKCmBDG\downloaded_packages
ERROR
cannot change to directory 'C:\Users\My'
The system cannot find the path specified.
Error in (function (command = NULL, args = character(), error_on_status =
TRUE, :
System command error
From some research, including this post and this post, I realise that this is a common issue, but none of the answers I can find help me work around this in papaja.
For info, I don't have this problem when installing other packages using install.packages().
I have managed to solve this problem after hours and hours of googling. The problem is not papaja; it is the presence of spaces in the path, which devtools does not deal with well.
To solve this, I first changed my library path:
.libPaths("C:/Program Files/R/R-3.6.1/library") # for R v.3.6.1
At first I couldn't get this to work - I kept getting the error 'lib = "C:/Program Files/R/R-3.6.1/library"' is not writable. Basically, this is because I did not have permission to write into this folder. To fix this, you simply close RStudio, go to the folder where the programme is saved and right click, then select 'Run as administrator'.

RStudio v1.1.456 Rpubs upload error, no login prompt

Hi I couldn't find any useful information in regards to this one.
When I try to publish to Rpubs on Rstudio v1.1.456, instead of login prompt I get this error message below.
[Edited] Rstudio v1.1.456, R v3.5.1
Upload Error Occurred Error in if (result$status == 201) succeeded <-
TRUE : missing value where TRUE/FALSE needed Calls: In
addition: Warning message: In http(protocol, "api.rpubs.com", port,
method, path, headers, : NAs introduced by coercion Execution
halted
I've already addded this line
options(rpubs.upload.method = "internal")
to both global and working directory Rprofile
Apparently, there was an issue in the most recent version of rsconnect (0.8.12).
devtools::install_github("rstudio/rsconnect", ref = "bugfix/multi-status-header")
Installing the patch solves it.

write_csv Error in stream_delim_(df, path, ...) : invalid connection

I have a doubt about why write_csv is not working in the following example, but write.csv is working properly. In general, I use the packages "dplyr" and "readr" as they are fast. However, I am not sure why this is happening.
write_csv(df1, path = "C:\\Users\\Sergio\\final\\file1.csv" ,col_names = TRUE)
I get the following error message:
Error in stream_delim_(df, path, ...) : invalid connection
However, if I write the following code, it works ok.
write.csv(df1, file = "file1.csv", fileEncoding="UTF-8")
I am using R version 3.4.1 64-bit, and RStudio Version 1.0.143. My OS is Windows 10. I would appreciate your comments. Thanks in advance.
You may have misspecified the file path. You should make sure both commands point to the same directory:
write.csv(df1, file = "C:\\Users\\Sergio\\final\\file1.csv", fileEncoding="UTF-8")
If that fails, you've misspecified the directory.

Resources