Problem installing packages in R "unable to create temporary directory" - r

I am having problems installing packages in Rstudio, I tried to install "nortest" among others and it keeps saying the following error:
> install.packages("nortest")
Installing package into ‘C:/Users/meliv/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
Warning in install.packages :
'lib = "C:/Users/meliv/Documents/R/win-library/3.6"' is not writable
probando la URL
'https://cran.rstudio.com/bin/windows/contrib/3.6/nortest_1.0-4.zip'
Content type 'application/zip' length 39063 bytes (38 KB)
downloaded 38 KB
Warning in install.packages :
cannot create dir 'C:\Users\meliv\Documents\R\win-library\3.6\file408c43245306', reason 'No such file or directory'
Error in install.packages : unable to create temporary directory ‘C:\Users\meliv\Documents\R\win-library\3.6\file408c43245306’
I tried unchecking the folder's "read-only" feature but made no difference.
Hope someone can help me. Thanks
Ps. I have Windows 10

Instead of unchecking the folder's "read-only" feature, try checking the "write" permission to the user.
It worked for me. Hope it works for you as well.
[EDIT] Additionally, you can run R as an administrator, that also works.

Do the below:
Run getwd()
Run .libPaths()
Copy the directory where it says program files.
Run .libPaths(Paste the directory you copied with the quote marks)
Run .libPaths () with no argument.
Try installing your packages

Related

'lib = "C:/Users/xxx/Documents/R/win-library/4.0"' is not writable

I realize that there are many similar topics such a mine, but none of the appear to resolve my issues. From one day to the next I am now unable to install any packages. I always get the following error:
> install.packages("gapminder")
Installing package into ‘C:/Users/mario/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
'lib = "C:/Users/mario/Documents/R/win-library/4.0"' is not writable
If I then chose the option to 'use a personal library instead' I get:
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/gapminder_0.3.0.zip'
Content type 'application/zip' length 2031853 bytes (1.9 MB)
downloaded 1.9 MB
Warning in install.packages :
cannot create dir 'C:\Users\mario\Documents\R\win-library\4.0\filecb869a32b3e', reason 'No such file or directory'
Error in install.packages : unable to create temporary directory ‘C:\Users\mario\Documents\R\win-library\4.0\filecb869a32b3e’
Googling on SO and other places suggests that this is a permission issue. Howver, I double checked and I am running RStudio under admin permission and I have double-checked that both RStudio and R 4.0 have full read/write privilege for admins:
and for regular users:
The library folder exists and is full of all the libraries that I always use:
And I believe this is independent of RStudio since going straight to R and trying to install from there leads to the same problems:
I am running Windows 10 Home 10.0.19041
After way too many hours of frustration I found the culprit:
Turning off real-time protection on Windows Security fixes the issue:
> install.packages("gapminder")
Installing package into ‘C:/Users/mario/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/gapminder_0.3.0.zip'
Content type 'application/zip' length 2031853 bytes (1.9 MB)
downloaded 1.9 MB
package ‘gapminder’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\mario\AppData\Local\Temp\RtmpGi9Jo9\downloaded_packages
That explains why the problem appeared from one day to the next (Windows 10 update) and why it doesn't show on my work laptop (IT-managed updates). Now to figure out how to put R/RStudio on the exclusion list rather than shutting this option off completely.
Mario's solution solved the problem. You can turn on real time protection and go to controlled folder access. When you click on the button, scroll down in the menu to allow an app through controlled folder access.
When you click on add an allowed app and then click on the recently blocked app, just whitelist R apps.

Error when installing package ‘openNLPmodels.en’ in R / RStudio. Error: cannot open URL 'http://datacube.wu.ac.at/src/contrib/PACKAGES.rds'

When I try to install package ‘openNLPmodels.en’ in RStudio I get the following error messages:
I run the latest versions of RStudio an R. openNLP and openNLPdata are correctly installed. Can you help me to install the package? Thank you very much in advance.
install.packages("openNLPmodels.en", dependencies=TRUE, repos =
"http://datacube.wu.ac.at/", type = "source", INSTALL_opts = c('--no-lock'))
Warning in install.packages :
cannot open URL 'http://datacube.wu.ac.at/src/contrib/PACKAGES.rds': HTTP status was '404 Not Found'
trying URL 'http://datacube.wu.ac.at/src/contrib/openNLPmodels.en_1.5-1.tar.gz'
Content type 'application/x-gzip' length 77794529 bytes (74.2 MB)
downloaded 74.2 MB
'\\WWG00M.ROOTDOM.NET\DFS\HOME\wt2rrib'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
ERROR: unable to create '\\Wwg00m.rootdom.net/dfs/HOME/WT2RRIB/R/Sentimental Analysis/openNLPmodels.en'
In R CMD INSTALL
Warning in install.packages :
installation of package ‘openNLPmodels.en’ had non-zero exit status
The problem is not installing openNLP. The problem is about manually installing the accompanying corpus in the language of your choice. Here are the options for the different languages in https://datacube.wu.ac.at/src/contrib/
openNLPmodels.da_1.5-2.tar.gz
openNLPmodels.de_1.5-2.tar.gz
openNLPmodels.en_1.5-1.tar.gz
openNLPmodels.es_1.5-1.tar.gz
openNLPmodels.it_1.5-1.tar.gz
openNLPmodels.nl_1.5-2.tar.gz
openNLPmodels.pt_1.5-2.tar.gz
openNLPmodels.sv_1.5-2.tar.gz
In your question, you are choosing English, so download the following onto your localhost: https://datacube.wu.ac.at/src/contrib/openNLPmodels.en_1.5-1.tar.gz
Manually install it into RStudio by selecting the tar.gz option:
Now you've got the English corpus installed for text mining with openNLP.

Install ggplot2 from local directory

I need to download packages and install from local directory. But I'm having trouble installing ggplot2. I get no warning, but it seems the library is not installed. Output is below, any suggestions? Operating system is Windows. After running, the directory C:...\R\win-library\3.1 contains subdirectory ggplot2-master.
> install.packages("C:/.../packages/ggplot2-master.zip", repos = NULL, type="source")
Installing package into ‘C:/.../R/win-library/3.1’
(as ‘lib’ is unspecified)
> library(ggplot2)
Error in library(ggplot2) : there is no package called ‘ggplot2’
The correct action was to download the binaries instead of the source.
Note, the following command prompts for the file path:
install.packages(file.choose(), repos=NULL)
The computer is behind a firewall, so the install.package command does not work. I should have downloaded the binary install, but downloaded the source by mistake. So, the corrective action is to download the binary files. I want to point out that in my notes on R, it clearly states to download the binary file. Part of the joys of getting older, not remembering why I came into this room.... Also, rambling...

Error installing RMySQL

It took a good amount of time to install RMySQL on my Linux machine but I was able to install it after changing environment variables and copy and paste lib.dll file.
However, I'm now trying to install RMySQL on my 64bit window machine, but so far there's no progress yet for two days. It broke down after "running command sh ./configure.win had status 127 error, and I cannot find what this means.
Can anyone shed some lights on this?
install.packages('RMySQL',type='source')
Installing package into ‘C:/Users/chu/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/RMySQL_0.9-3.tar.gz'
Content type 'application/x-gzip' length 165363 bytes (161 Kb)
opened URL
downloaded 161 Kb
* installing *source* package 'RMySQL' ...
** package 'RMySQL' successfully unpacked and MD5 sums checked
Warning: running command 'sh ./configure.win' had status 127
ERROR: configuration failed for package 'RMySQL'
* removing 'C:/Users/chu/Documents/R/win-library/3.1/RMySQL'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-31~1.0/bin/x64/R" CMD INSTALL -l "C:\Users\chu\Documents\R\win-library\3.1" C:\Users\chu\AppData\Local\Temp\RtmpKA9e7I/downloaded_packages/RMySQL_0.9-3.tar.gz' had status 1
Warning in install.packages :
installation of package ‘RMySQL’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\chu\AppData\Local\Temp\RtmpKA9e7I\downloaded_packages’
for linux users..
install- libmysql first
sudo apt-get install libmysql++-dev
then try.
I was facing the same error. Given below is the link to a way around that worked for me.
http://www.ahschulz.de/2013/07/23/installing-rmysql-under-windows/
In short, the location of library libmysqll.dll required for compilation, had to be changed from lib folder to bin folder of the home directory set for MySQL in environment variables.
By default, R uses the /tmp directory to install packages. On security conscious machines, the /tmp directory is often marked as “noexec” in the /etc/fstab file. This means that no file under /tmp can ever be executed. Packages that require compilation or that have self-inflating data will fail with the error mentioned.
The solution is to set the TMPDIR environment variable outside R (in your shell), which R will use as the compilation directory. How to do this depends on the shell. bash:
mkdir ~/tmp
export TMPDIR=~/tmp
Then R can compile and install the package.
I ran into the same problem while updating packages on Windows server for latest version of R. I solved it by installing from a .zip file vs .tar.gz.
I actually had to go through the process of first downloading the package, and then installing from it (not from mirror) for other reasons.
Here is what it looked like:
pk <- 'caTools'
download.packages(pk, "R-3.2-packages/" ,type = "win.binary")
install.packages(
dir("R-3.2-packages/",pattern=pk,full.names = TRUE),
repos = NULL,
type = "source")
Hope this helps.
Solution if anyone faced the same problem on windows:
Make sure your MYSQL_HOME environment variable is set correctly and libmysql.dll is copied to bin folder!!!
Run install.packages('RMySQL') then when the "Do you want to install from sources..." window pops up select No.
Then copy the downloaded binary packages location from console.
Go to Packages -> Install, paste the location into Package archive and click Install.

Install R package to a specific directory

I tried this code to install R package to a directory where I stored my R packages.
install.packages("zoo", lib="/data/Rpackages/")
I got this warning message:
Warning in install.packages("zoo", lib = "/data/Rpackages/") : 'lib
= "/data/Rpackages/"' is not writable
Secondly how do I create a file .Renviron in our home area and add the line R_LIBS=/data/Rpackages/ to it?
How do you actually get out of the warning situation? Is there a better way other than (in R Studio menus) Session->Interrupt R and terminating the R session? I tried CTRL-C.
> install.packages("car", lib="/my R packages/")
Warning in install.packages :
'lib = "/my R packages/"' is not writable
My solution to the problem was to load the package within R Studio using the 'Packages' window which then does the following:
> install.packages("car")
Installing package into ‘C:/Users/33386/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/car_2.0-21.zip'
Content type 'application/zip' length 1332800 bytes (1.3 Mb)
opened URL
downloaded 1.3 Mb
package ‘car’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\33386\AppData\Local\Temp\RtmpKWnZD4\downloaded_packages
>
Briefly:
Use chmod to change the directory mode: chmod u+w /data/R/packages. You may need sudo (or your admin) to do that.
Use an editor and create and save a file: editor ~/.Renviron. You could also copy Renviron.site from R's etc/ directory and start from that.
Try running R studio as administrator. If you are using ubuntu start R using
sudo R

Resources