Installing R packages - HPC Cluster - r

I am trying to install some R packages on my account on the HPC cluster. However when I do that I get the following error:
no permission to install to directory '/gpfs1/apps/sw/R/R-3.6.1/lib64/R/library'
I have contacted the admin and he told me I do need admin privilages to install anything to /gpfs1/apps/sw/. He told I must rather do that in the home directory.
How can I switch to the home directory on my account ? The admin has already installed some other R packages on my account but I need to install some myself ? How do I know where my R packages are on the home directory and how to install everything there ?
Output of .libPaths()
"/gpfs1/apps/sw/R/R-3.6.1/lib64/R/library"
Update
Using the following tutorial I am now able to install R packages in my home directory on the cluster using the following command:
export R_LIBS_USER=/home/rcf-proj/tt/trojan/R/parallel:$R_LIBS_USER
which adds the path above to .libPaths(). However, when running my R script it keeps referring to the original location /gpfs1/apps/sw/R/R-3.6.1/lib64/R/library where I don't have the packages I installed in my HOME directory. Especially that after I restart R, I must always do this command.
In the answers here They recommended I edit the .libPaths() in the .Rprofile file, but I cannot seem to find it on my cluster account. The same issue is still open here
I have read it somewhere that we car create a .Rprofile ourselves, but how can I do this and what must I put in it ??

Related

R (and Bioconductor) cant install packages "path not writable/access denied"

I am using R again after some time and need to install various packages (e.g. lumi, GENAVi, ideal, limma) and for some the installation works for some not. I receive failure notifications indicating that I the library paths are not writable or that access is denied.
installation of lumi with bioconductor fails
thus, lumi appears to be not existing
My PC uses windows 10, recently updated, and R 4.1.1
I tried the following steps (based on older forum entries):
I ran R Studio with administrator permissions
I gave R full permission through the firewall of my antivirus program
I gave R permission through the windows security settings
I reinstalled R on another harddrive (E:/) where it should have full permission for all paths.
I added a path in the xxx
I ran R inside a new environment in the “Conda” software, but the permission problems persisted.
(Outside of Conda) I installed the lumi package out of a zip file (instead of a Bioconductor download). Still didnt work...
So I now don’t know what to do anymore and barely find new ideas for solving the problem.
I appreciate your help

Installing packages R (Ubuntu)

I have a problem with R, I haven't experienced before. Before writing here I checked the forums but couldn't solved my problem. I saw somebody experiencing this problem.
First, I use Ubuntu 16.04 and R 3.4.1 (Single candle). But I can not install any packages. First it said the directory is not writeable and if I want to create a personal library?
lib = "/usr/local/lib/R/site-library"' is not writeable Would you like
to use a personal library instead? (y/n)
I couldn't :( I checked forums another option was changing permission, i coded:
1. cd /usr/local/lib/R
2. sudo chmod o+w site-library
3. ls -l but it didn't work.
When I want to download a package, it installs it at /tmp folder. And i can not use it, cause when i want to open it with "library()" it says there is no package like that. I copied the package from the /tmp folder and pasted it to the folder other packages are (i didn't installed them by myself, they were there) but still it doesn't recognize the package.
I didn't experienced this with my windows pc, and a friend with Ubuntu said he is usind R and Rstudio without problem. So what is wrong with mine :( ???
The problem is that r or rstudio doesn't have permission to write inside theses directories.
You should change your R_LIBS for a local directory, take a look in /etc/R/Renviron.site and uncomment the R_LIBS line or define it if needed.
Check if a R folder exists in your home like this ~/R/x86_64-pc-linux-gnu-library/3.4, it should be your R_LIBS address. If it doesn't exist you can create one like ~/R/library/ and define the same in Renviron.site.
More information, check here or help(Startup).

Installing package - cannot open file - permission denied

I'm working in RStudio and am attempting to install the dplyr package. I have installed various other packages without problem but have hit a problem with this.
It seems there are various parts to the install, some of these worked but the problem happens when I get 'the dependency BH'. This is the error:
>Installing package into ‘\\xxxxxxxx.local/Desktops/jagnew/My Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
also installing the dependency ‘BH’
>trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/BH_1.62.0-1.zip'
Content type 'application/zip' length 16150075 bytes (15.4 MB)
downloaded 15.4 MB
>trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/dplyr_0.5.0.zip'
Content type 'application/zip' length 2556205 bytes (2.4 MB)
downloaded 2.4 MB
>Error in install.packages : cannot open file '\\xxxxxxx.local/Desktops/jagnew/My Documents/R/win-library/3.3/file142032c9327b/BH/include/boost/function/detail/gen_maybe_include.pl': Permission denied
I have changed the directory/libpath as it did not appear that the file was downloading to the correct folder. file142032c9327b is now in the correct path, but path specified in the error is only correct up to /boost, there is no function folder here..?
I'm not sure if this missing folder is the issue, as the error says 'Permission denied', but it seems odd.
I had the same issue. Tried doing the following and worked for me:
Run the RStudio as administrator
Under the Packages tab, click Install and change Install to Library option to C:/Program...../R/../library and select the desired package to install.
Hope it works.
I had the same problem. R gave me an error message whenever I tried to install a new, or update an existing package. I don't remember what the message said exactly, but it was saying "Cannot open file (...) access denied". I tried all the following. Not sure what exactly fixed the problem, but now I can update and/or install new packages:
Open R/RStudio as administrator;
Change the R library folder (where packages are installed) security settings, and grant full access to my computer user account. Link1, link2;
(I think this was what fixed the problem) Follow instructions on this link. It prompted me to install another package, "devtools". Then it worked.
Well, I think my problem was a special case, but it might benefit someone. I had the Windows Defender Ransomware Protection set to ON. That was blocking rsession.exe by default. Allowing rsession.exe solved the problem.
TL;DR
The "Documents" (or "My Documents") directory is a special location in Windows. I don't know if the system itself processes its permissions differently or if antiviruses target operations inside this directory more strictly, but many R users have issues installing packages in the personal library inside this folder (even if running R as administrator). Other answers haven't worked.
For me, what solved the problem was to put the personal library directly under X:\\Users\username\ instead of under Documents, which is the R default on Windows. To make it permanent, I set a user environment variable R_USER to %USERPROFILE%. Here is a nice guide of how to set environment variables in Windows.
Note: after this change, you may need to move your .Rprofile, .Renviron, etc. files from Documents to the user profile directory.
Details
The default location for R's user "home" directory on Windows is X:\\Users\username\Documents. This is because there is no concept of HOME in Windows, just of a "personal" directory (Documents): https://cran.r-project.org/bin/windows/base/rw-FAQ.html#What-are-HOME-and-working-directories_003f
Therefore, by default, the personal library location is under X:\\Users\username\Documents\R\win-library\X.Y\. You can get the exact location on your machine with this command in the R console:
Sys.getenv('R_LIBS_USER')
I was getting this same cannot open file error when trying to install or update packages, even when running as administrator. I suspected of directory permissions, checked it within the directories' "properties" without luck. Removed the whole R\win-library tree and recreated it and nothing... Finally, I tried to move the personal library location to my users' directory:
.libPaths('X://Users/username/R/win-library/X.Y/')
And it worked!
Warning in install.packages :
cannot create file '/usr/local/Cellar/r/3.6.2/lib/R/doc/html/packages.html', reason 'Permission denied'
Warning in install.packages :
cannot update HTML package index
I had the same permission issue when trying to download a pkg--ISLR. Fixed it after following the above answers.
In case, some are new to R studio like me. These were my steps to install a pkg.
Click Terminal next to Console in R studio
Type sudo r, to run r as an administrator
install.packages("ISLR") to install your package
--- Please select a CRAN mirror for use in this session ---
https://cran.rstudio.com/src/contrib/ISLR_1.2.tar.gz
Secure CRAN mirrors
1: 0-Cloud [https] 2: Australia (Canberra) [https]
3: Australia (Melbourne 1) [https] 4: Australia (Melbourne 2) [https]
Pick a number -- a mirror site, then click enter.
Voilà! Package installed.
I had faced also this issue. The one and only solution that helped me was to turn off my firewall. Then I was able to download all packages.
The problem solved for me after running R in admin mode and disabling Antivirus.
Translating #Shubham Yadav's answer to code mode would be something like this: install.packages("your_package", lib = "C:/Program Files/R/R-4.0.3/library")
It's working for me (running RStudio as admin, course).
This procedure worked for me.
Removed existing package with remove.packages()
ran RStudio as an admin
Installed by specifying the libpath: devtools::install_github('https://github.com/Rdatatable/data.table/tree/frollmax', lib=.libPaths()[2])
For me what worked was manually deleting within the library directory the folder that I had problem with updating. And then install.package() again.
I had faced the same issue.
I tried below steps to resolve this issue:
Launch RGui application.
Go to Packages section and select Install Packages.
Select the Package that you want to install from the Packages pop up window.
And click OK, that's it package will get successfully installed.
After following above steps, you can run use your package from RStudio.
I ran into this issue today where rlang couldn't install the newest version and so tidyverse wouldn't work. I tried running as admin, changing install location, running as admin, permitting rstudio through Windows Defender Randsomware Protection, and installing DevTools. The only thing that worked was to uninstall RStudio, reboot, reinstall.

How to install stringi from local file (ABSOLUTELY no Internet Access)

I am working on a remote server using RStudio. This server has no access to the Internet. I would like to install the package "stringi." I have looked at this stackoverflow article, but whenever I use the command
install.packages("stringi_0.5-5.tar.gz",
configure.vars="ICUDT_DIR=/my/directory/for/icudt.zip")
It simply tries to access the Internet, which it cannot do. Up until now I have been using Tools -> Install Packages -> Install from Packaged Archive File. However, due to this error, I can no longer use this method.
How can I install this package?
If you have no internet access on local machines, you can build a distributable source package that includes all the required
ICU data files (for off-line use) by omitting some relevant lines in
the .Rbuildignore file. The following command sequence should do the trick:
wget https://github.com/gagolews/stringi/archive/master.zip -O stringi.zip
unzip stringi.zip
sed -i '/\/icu..\/data/d' stringi-master/.Rbuildignore
R CMD build stringi-master
Assuming the most recent development version is 1.3.1,
a file named stringi_1.3.1.tar.gz is created in the current working directory.
The package can now be installed (the source bundle may be propagated via
scp etc.) by executing:
R CMD INSTALL stringi_1.3.1.tar.gz
or by calling install.packages("stringi_1.3.1.tar.gz", repos=NULL),
from within an R session.
For a Linux machine the easiest way is from my point of view:
Download the release you need from Rexamine in tar.gz format to your local pc. In opposition to the version on CRAN it already contains the icu55\data\ folder.
Move the archive to your target linux machine without internet access
run R CMD INSTALL stringi-1.0-1.tar.gz (in case of release 1.0-1)
You provided the wrong value of configure.vars.
It indicates that you have to give the directory's name, not a final file name.
Correct your code to the following:
install.packages("stringi_0.5-5.tar.gz",
configure.vars="ICUDT_DIR=/my/directory/for/")
Regards,
Sean
Follow the steps below
Download icudt55l.zip seperately from server where you have internet access with
wget http://www.mini.pw.edu.pl/~gagolews/stringi/icudt55l.zip
Copy the downloaded packages to the server where you want to install stringi
Execute the following command
R CMD INSTALL --configure-vars='ICUDT_DIR=/tmp/ALL' stringi_1.1.6.tar.gz
icudt55l.zip is copied to /tmp/ALL
The suggestion from #gagolews almost worked for me. Here's what actually did the trick with RStudio.
Download the master.zip file that will save as stringi-master.zip.
Unzip the file onto your desktop. The unzipped folder should be stringi-master.
Edit the .Rbuildignore file by removing ^src/icu55/data and ^src/icu61/data or similar lines.
Move the folder from your desktop to the home directory of your server.
Create a New Project in RStudio with ~/stringi-master as the Existing Directory
From RStudio's menu, select Build and Build Source Package. (You may need to first select Configure Build Tools. For Project build tools choose Package then select OK.)
It should create a tar.gz file, in the following format: stringi_x.x.(x+1).tar.gz. For example, if the current version of stringi is 1.5.3, it will create version 1.5.4. (I received a few warnings that didn't seem to affect the outcome.)
Move the newly created package to your local repository. Update the repository index. And install the package.

Move r packages to new computer which has no internet

Normally I install packages using:
install.packages("foo")
and a Repo over the internet. But I have a new machine now where I want to replicate the packages from my existing installation without having to pull everything off the internet all over again. (I've a ton of packages and slow internet access)
Both machines are Windows and run the same R version. (2.13.1)
Is there a way to do this? Closest I can get is I know I can install from local zip files using:
install.packages("pathtozip", repos = NULL)
But does R store all Zips somewhere? I found a few in locations like:
C:\Documents and Settings\foouser\Local Settings\Temp\RtmpjNKkyp\downloaded_packages
But not all.
Any tips?
The function .libPaths will give you a vector of all the libraries on your machine. Run this on your old machine to find all of them. You can simply copy all these files into the libraries on your new machine (run .libPaths on it too to find out where).
Alternatively, if you want to set up a real repository (i.e. basically a CRAN mirror) on your computer or on a network drive you can update, you can put binary or source packages into a folder and run tools::write_PACKAGES on that folder. You can them run install.packages using the contriburl argument and point it to your repository folder.
All packages that you have installed are stored in a folder called win-library\r-version, for example,
C:\Users\Ehsan\Documents\R\win-library\2.15 so, it is enough to copy all the folders inside 2.15 to the same folder in your new machine. because you have the same version of R you do not need to update them by update.packages().
On your original computer, run
write.csv(unique(data.frame(installed.packages())[,1]),"packages.csv",row.names=F)
Save this .csv into the working directory of your new computer, then run
install.packages(as.character(read.csv("packages.csv")[,1]))
You can check what your working directory is using getwd().

Resources