How do I get Rtools 3.0 working for R 3.0? R can't find the installation - r

I'm trying to get R to recognize that I have installed Rtools.exe. I've tried installing it in several different locations. However, whenever I restart R and load devtools I get the same error:
> library(devtools)
WARNING: Rtools is required to build R packages, but is not currently installed.
Please download and install Rtools 3.0 from http://cran.r-project.org/bin/windows
/Rtools/ and then run find_rtools().
Naturally, whenever I try the function find_rtools() I get the same error message. I'm done trying to figure this out with help files, as the devtools help doesn't offer much. I've tried installing in several of the locations returned by get_path() but the problem persists.
FYI, currently my R is installed at D:/R.
Has anyone else had this problem, and more importantly, can anyone help me?
I'm sorry if this is a duplicate, and I've tried to include as many relevant details as possible so if you need any clarification please let me know.
Thanks,
Nick

Grab the batch file Rpathset.bat from batchfiles, edit the SET statements in it appropriately and then run R like this from the Windows console:
Rpathset
Rgui

I ran into this issue running a Windows 7 machine without admin rights. I leveraged G. Grothendieck's response, with a few additional steps.
Get Rpathset.bat from https://code.google.com/p/batchfiles/
Edit the Set statements in Rpathset.bat to your paths
Run CMD and change directories to where Rpathset.bat is stored
In the command prompt, run rpathset.bat > mypath.txt
Open mypath.txt with a text editor
Click Windows Start and search for environment
Click Edit environment variables for your account
Click path and then edit
Copy and paste the entire path from mypath.txt into the Windows path (everything after the path statement)
Restart RStudio and check that devtools::find_rtools() is TRUE

This file rtools.r contains the code for find_rtools(). It looks like it is trying to find ls and gcc in your system path (and then does some more checks based on the version) and if that fails it tries to look up SOFTWARE\R-core\Rtools in the the Windows registry.

As Thomas mentioned here, "Rtools is not a package." This is what I did to install Rtools. My RStudio is running R version 3.1.3. So I downloaded Rtools31.exe from https://cran.r-project.org/bin/windows/Rtools/. I executed the exe file, selected all the default options in the Setup Wizard and installed. (I had admin privilege on the computer I was using but I am not sure if that makes any difference.) To check that it was properly installed, you can enter find_rtools() in the R prompt which should return TRUE if Rtools installed properly.
For R 3.0, you probably just need to download Rtools30.exe and follow the same steps above.

I ran into this problem trying to install Rtools33 to use Hadley Wickham's lineprof package. I got that error multiple times. I'm running Windows 7 on a laptop.
I was able to fix the problem by running the Rtools installation file as the windows Admin (i.e. right-click the Rtools33.exe and choose "Run as administrator")
I also made sure to point the path to the R source directory, which I kept in C:\Rtools\ (which contains C:\Rtools\bin\ and C:\Rtools\gcc-4.6.3\).
This solved the problem for me and I am now able to install lineprof from GitHub and make use of it.

Related

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 build qpdf on Windows?

When running the checks for my R-package (via devtools::check()) I face the warning ''qpdf' is needed for checks on size reduction of PDFs. I found this question were it was suggested (if I understood the answer correctly) to run Sys.which(Sys.getenv("R_QPDF", "qpdf")) and see whether qpdf is found or not. In my case this just returns
qpdf
""
so, I think I didn't install qpdf correctly. Unfortunately it seems to be quite complicated to install qpdf on Windows. My first side question is: does it really is so painful and complicated to install qpdf for Windows or is there an easy solution?
I've followed the instructions until it is said to add C:\MinGW-w64\bin and C:\MinGW-w64\lib\mingw to the PATH variable. But then I don't find further specific instructions to install qpdf, only about how to build qpdf with different other programs. The second side question is: is my assumption correct that after I've build qpdf it is installed? But the real question is: What is the best way to build qpdf? I tried the ./config-mingw32 and ./config-mingw64 commands from the section "Building with MinGW" in my C:\MinGW\msys\1.0\bin\bash.exe but got the error messages ./config-mingw32: No such file or directory and have no idea how to fix this issue.
I'm using Windows 10, R version 3.3.2 Patched (2017-01-07 r71934) -- "Sincere Pumpkin Patch" and RStudio 1.0.136.
You basically do not need to build the file on windows. Please follow three steps below:
Download qpdf for windows from https://sourceforge.net/projects/qpdf/?source=typ_redirect
Extract files in a temp folder
Copy the contents of the bin folder to %SystemRoot%\System32
job done!
Sys.which(Sys.getenv("R_QPDF", "qpdf"))
qpdf
"C:\\WINDOWS\\SYSTEM32\\qpdf.exe"
To flesh out an answer provided elsewhere:
If you are running the 32-bit version of R, it is important that you download the 32-bit version of qpdf, which is the version linked from the SourceForge homepage. If you are running a 64-bit installation of R, you will need to do a bit of digging to locate the 64-bit version of qpdf, which is buried a little more deeply (version 10.0.1 is listed here).
Rather than copying files to C:/Windows/System32, a potentially safer option is to extracted the zipped qpdf directory to C:\Program Files. If you do this, you'll need to add C:\Program Files\qpdf-version_number\bin to your system PATH under the environment variables.
To do this within R, run Sys.setenv('PATH' = paste0('C:\Program Files\qpdf-version_numer\bin;', Sys.getenv('PATH')))
To do this in Windows, open the start menu, type "edit the system environment variables" to open the System Properties, and at the bottom of the "Advanced" tab click "Environment variables". Find the "Path" entry under "System variables" and click "Edit". Then, re-start R so it picks up the modified PATH.
One further step may be required to convince Windows that pqdf is safe to run.
Navigate to C:\Program Files\qpdf-version_numer\bin and execute qpdf.exe (by double-clicking). Windows 10 throws up a security warning, as it's an unrecognized executable file. You'll need to use the more options link to find the button to run the program. This done, Windows will recognize the file as safe to run and allow other software, including R, to use it.

Passing argument to R with Command Prompt [duplicate]

I'm exploring package building on Windows 7 but have been running into trouble after reaching the Command Prompt stage. The following thread appears to be on the same topic that I'm having trouble with, but the question remains unresolved:
Cannot install R package in Windows 7
The problem: whenever I try an R CMD command in Command Prompt (e.g. I've tried R CMD install pkgName, R cmd install pkgName, Rcmd install pkgName, where pkgName is a place-holder for an actual package that has been R CMD checked on OS X and also posted on CRAN, where I have the unzipped source in the current working directory), I get the following error message:
'R' is not recognized as an internal or external command,
operable program or batch file.
(If I try the Rcmd install pkgName command, then the error starts out as 'Rcmd' is not ....) Note that even if I type in just R in Command Prompt and hit enter, I get the same error, so I'm not even able to bring up R here, though it opens perfectly fine in its stand-alone interface.
I have examined the following guides without success in identifying the trouble:
Karl W Broman's website
Rob J Hyndman's website
Steven Mosher's blog
The most immediate thing that came to mind was that the path variables in Windows were not set right, but this also has not (yet) led to the answer. For example, I have triple-checked the paths to ensure they are correct, including for the R version number, that x64 in the path name is accurate, etc.
I realize this is a complex issue to remotely diagnose, but any advice and suggestions on resolving this trouble is appreciated. For reference, below are the steps I have taken already to try to resolve this issue:
Uninstall R and Rtools
Install the latest version of R (2.15.0)
Install Rtools215 to match R version 2.15.0
Originally I let Rtools specify the path variables (turning that option on during installation). No success after this method.
I updated the path variables on my computer, where the below paths were used:
C:\Rtools\bin; C:\Program Files\R\R-2.15.0\bin\x64;
I've also tried the R CMD (and Rcmd) commands with the following paths included (note that these paths don't lead to anything on my computer, so I tried doing R CMD / Rcmd with and without them specified):
C:\Rtools\perl\bin; C:\Rtools\MinGW\bin;
Tried adding/removing the following path, which goes to the only other folder visible within the Rtools folder:
C:\Rtools\gcc-4.6.3;
Tried multiple variations of the R CMD commands, as noted earlier.
I tried this all a few months ago when I had R version 2.14.1 and Rtools214 installed, and I had the exact same trouble.
Note: I already had Cygwin installed prior to R and Rtools, and I have not installed MikTeX (yet).
Have you closed the command prompt and opened a new one after adjusting the PATH?
Enter the command PATH on the command line and ensure that you are properly updating your path
Try navigating to the directory where R.exe is saved and running it locally -- cd C:\Program...\bin\x64, R.exe.
Ensure that you're running on Windows' Command Prompt and not Cygwin's terminal
If you actually have a space after the semi-colon in your PATH, you'll need to remove that: /bin;C:/Program.... Try combining that with Joshua's solution.
I attach my whole solution here:
Install Rtools which is compatible with my R version
Add PATH: C:\Program Files\R\R-2.15.1\bin\x64;C:\Rtools\bin;C:\Rtools\gcc-4.6.3\bin
In cmd, enter: R CMD INSTALL packagename
Click "enter", done.
I had a lot of trouble getting this to work, and finally found the golden nugget on r-project (R doesn't like spaces in paths) so here's how I finally did all this:
I installed R to "c:\programs" instead of "c:\program files...". My final path to RSCRIPT.exe is "C:\Programs\R\R-2.15.2\bin\Rscript.exe"
I added that directory to my PATH, but that doesn't seem to help
RStudio is also installed under c:\Programs (e.g. c:\Programs\RStudio), but RTools is installed under the "c:\" root directory (e.g. c:\RTools).
I downloaded all the packages to "c:\downloads\r"
I opened a command prompt in "c:\downloads\r" and ran the R CMD install from this downloads directory, specifying the path to R
e.g. "C:\Programs\R\R-2.15.2\bin\x64\R CMD INSTALL colorspace_1.2-0.zip"
It appears that the CMD processor is Case Sensitive. You have to use INSTALL vs. install
Simple solution, use quotes:
c:> "C:\Program Files\WinZip\wzunzip.exe"
if you run this, you don't need to worry about the space in Program Files.
Hope this help.
I encountered a similar problem while trying to use SparkR from Windows Power Shell. Each time I would do ".\sparkR.cmd" (I was inside the folder containing this file), it would throw an error message like,
cmd is not recognized as an internal and external
command...blah...blah...blah.
I solved the problem by adding "C:\Windows\System32" to my PATH.
I restarted my system and then repeated the process and this time, I saw a new error,
R is not recognized as an internal and external
command...blah...blah...blah.
I tried all sorts of approaches, including the ones mentioned above. NOTHING WORKED, I was probably wasn't efficient enough to make it work.
Then I came across this place at code.google. I simply copied the R.bat onto a notepad, named it as R.bat. Kept it inside the folder where sparkR.cmd was located. For me it was,
C:\Apache\spark-1.5.1-bin-hadoop2.6\bin\
The I placed it on my PATH as :
C:\Apache\spark-1.5.1-bin-hadoop2.6\bin\R.bat
Restarted my laptop, opened my Power Shell as an administrator and typed :
.\R.bat help
It worked fine. Then I typed,
.\sparkR.cmd
and there it was.
It worked.
I hope it helps to people new to R. Thank you G. Grothendieck.
In the .bat file add a line of code specifying the path of the folder where R is installed and then give the path of the script as follows -
#ECHO OFF
PATH C:\Program Files\R\R-3.5.1\bin
R CMD BATCH D:\project_abc\helloworld.R
Following this, run the .bat file and you will see the code in the script will run smoothly.
In my case the issue was solved by using Edit instead of New while selecting PATH in the window below:
enter image description here
After selecting Edit I added the directory below:
C:\Program Files\R\R-4.0.2\bin\x64
This solved the issue in my case.

Error while installing VIM package in R-2.15.3 [duplicate]

I am using R 2.13.0 with windows 7, after giving my user full privileges to the R folder (as described here).
This allows me to install new packages just fine.
However, when using update.packages(), to update existing packages, I keep getting the following error (for example, when updating the MASS package):
package 'MASS' successfully unpacked and MD5 sums checked
Warning: unable to move temporary installation
'C:\Program
Files\R\R-2.13.0\library\file6cae3bcf\MASS'
to 'C:\Program
Files\R\R-2.13.0\library\MASS'
Any suggestions on how to fix this?
p.s: Running R as an administrator or shifting the library location out of Program Files is not a solution (it's a hack - but I am looking for a solution)
I found that the problem indeed is the antivirus "real time file system protection". I do the following to fix the problem:
trace(utils:::unpackPkgZip, edit=TRUE)
I edit line 140 (line 142 in R 3.4.4):
Sys.sleep(0.5)
to:
Sys.sleep(2)
I seems like the antivirus stalls the creation of the package tmp dir. After changing it to 2 seconds the error is gone.
EDIT: to do this programmatically execute
trace(utils:::unpackPkgZip, quote(Sys.sleep(2)), at = which(grepl("Sys.sleep", body(utils:::unpackPkgZip), fixed = TRUE)))
(credits #DavidArenburg)
Just to update everyone, I (think that I) found out the source of the problem: antivirus.
The "real time file system protection" was blocking R from copying the files between folders once they were downloaded.
Upon adding the R directory to the exception list (coupled with adding user permission and installing R on D:\R), and the problem went away. With all of this work, I might as well switch to Linux (I should, really...)
(I updated my post with the above information: http://www.r-statistics.com/2011/04/how-to-upgrade-r-on-windows-7/)
I hope it will help someone in the future,
Tal
If you cannot turn off your antivirus, due to corporate policy for example, here is a workaround that I found. Debugging the unzip package function and then stepping through it gives the antivirus enough time to do its job without interfering. Use this command:
debug(utils:::unpackPkgZip)
install.packages("packageName")
and then step through the code (by pressing enter many times) when R starts debugging during the installation.
I found this solution here.
If you can just download the binary straight from CRAN. On windows when downloaded it will be a zip file. Now manually unzip this into the ..library/ folder of your R (.libPaths()). It worked for me on some packages.
I had this problem installing both swirl and dplyr. I am working on Windows 64-bit.
Warning: unable to move temporary installation
What I did is I accessed my temporary files on the C: drive, and opened my file extractor program and I extracted the files from the temp file in the C: drive to my R program files in the C: drive, by manually copying them. THIS WORKED FOR BOTH dpylr and swirl. Stoked!
Cheers,
Peach
Can you not use the lib.loc parameter to only update packages in your personal library (in user)?
There should be no way to enable a normal, non-augmented user to change files in the program files folder, so the only thing you can do (if you don't want to augment the user) is to have R not updating packages there.
A workaround is to avoid installing R in the program files folder (which may be more or less of a hack than just shifting the library location out of it, depending on your point of view).
Finally, if lib.loc doesn't cut it, you can look at the source code for update.packages and create your own customized version that will always avoid the common library location in program files.
I just met the same question, and the solution I found out was that you should install packages using the original R software (plus, you should choose the right mirror site, some of them are blocked). At first I used Rstudio to install packages and I got the same problem as you met. Hope this is helpful.
I have run into this error several times. In my own case, it is because our admins want us to use remote virtual disks (on Windows 7) for our files and everything is locked up tight as a drum. The only way I can use R packages is in a lib directory on that remote virtual disk. This wouldn't be a problem except that the network isn't always smooth and fast. Thus, when I need a package, especially one with several other packages in tow (e.g., MBESS), I either have to go through the get.packages() process multiple times until it finally finishes or make it IT's headache to do quick like the bunny for me. I can't always wait for IT.
I just went to the library folder (Windows XP) and deleted all fileXXXX folders. Reran the install an it is worked.
I had the same problem. Since the issue seems to be the antivirus blocking the transf of a downloaded file, I tried a different download method in the install.packages and it worked.
For example:
install.packages("stringr", method = "curl")
You must go into the properties of the R folder and change the security parameters. You can enable the option to write and modify for all users.
The error : "unable to move temporary installation" is basically arising due to any of the antivirus running on your system.
Try unzipping the downloaded file from the Temp folder into the default library path (you can get it by running .libPaths() in R session).
I'm using a MRAN and I was having so many versioning issues. Trying to work with tidyverse and ggplot2 and by upgrading to the latest version from Microsoft it solved all of my R-Studio versioning issues.
Version info:
Microsoft R Open 3.5.1
The enhanced R distribution from Microsoft
Default CRAN mirror snapshot taken on 2018-08-01.
Download Microsoft R Open 3.5.1

Windows 7, update.packages problem: "unable to move temporary installation"?

I am using R 2.13.0 with windows 7, after giving my user full privileges to the R folder (as described here).
This allows me to install new packages just fine.
However, when using update.packages(), to update existing packages, I keep getting the following error (for example, when updating the MASS package):
package 'MASS' successfully unpacked and MD5 sums checked
Warning: unable to move temporary installation
'C:\Program
Files\R\R-2.13.0\library\file6cae3bcf\MASS'
to 'C:\Program
Files\R\R-2.13.0\library\MASS'
Any suggestions on how to fix this?
p.s: Running R as an administrator or shifting the library location out of Program Files is not a solution (it's a hack - but I am looking for a solution)
I found that the problem indeed is the antivirus "real time file system protection". I do the following to fix the problem:
trace(utils:::unpackPkgZip, edit=TRUE)
I edit line 140 (line 142 in R 3.4.4):
Sys.sleep(0.5)
to:
Sys.sleep(2)
I seems like the antivirus stalls the creation of the package tmp dir. After changing it to 2 seconds the error is gone.
EDIT: to do this programmatically execute
trace(utils:::unpackPkgZip, quote(Sys.sleep(2)), at = which(grepl("Sys.sleep", body(utils:::unpackPkgZip), fixed = TRUE)))
(credits #DavidArenburg)
Just to update everyone, I (think that I) found out the source of the problem: antivirus.
The "real time file system protection" was blocking R from copying the files between folders once they were downloaded.
Upon adding the R directory to the exception list (coupled with adding user permission and installing R on D:\R), and the problem went away. With all of this work, I might as well switch to Linux (I should, really...)
(I updated my post with the above information: http://www.r-statistics.com/2011/04/how-to-upgrade-r-on-windows-7/)
I hope it will help someone in the future,
Tal
If you cannot turn off your antivirus, due to corporate policy for example, here is a workaround that I found. Debugging the unzip package function and then stepping through it gives the antivirus enough time to do its job without interfering. Use this command:
debug(utils:::unpackPkgZip)
install.packages("packageName")
and then step through the code (by pressing enter many times) when R starts debugging during the installation.
I found this solution here.
If you can just download the binary straight from CRAN. On windows when downloaded it will be a zip file. Now manually unzip this into the ..library/ folder of your R (.libPaths()). It worked for me on some packages.
I had this problem installing both swirl and dplyr. I am working on Windows 64-bit.
Warning: unable to move temporary installation
What I did is I accessed my temporary files on the C: drive, and opened my file extractor program and I extracted the files from the temp file in the C: drive to my R program files in the C: drive, by manually copying them. THIS WORKED FOR BOTH dpylr and swirl. Stoked!
Cheers,
Peach
Can you not use the lib.loc parameter to only update packages in your personal library (in user)?
There should be no way to enable a normal, non-augmented user to change files in the program files folder, so the only thing you can do (if you don't want to augment the user) is to have R not updating packages there.
A workaround is to avoid installing R in the program files folder (which may be more or less of a hack than just shifting the library location out of it, depending on your point of view).
Finally, if lib.loc doesn't cut it, you can look at the source code for update.packages and create your own customized version that will always avoid the common library location in program files.
I just met the same question, and the solution I found out was that you should install packages using the original R software (plus, you should choose the right mirror site, some of them are blocked). At first I used Rstudio to install packages and I got the same problem as you met. Hope this is helpful.
I have run into this error several times. In my own case, it is because our admins want us to use remote virtual disks (on Windows 7) for our files and everything is locked up tight as a drum. The only way I can use R packages is in a lib directory on that remote virtual disk. This wouldn't be a problem except that the network isn't always smooth and fast. Thus, when I need a package, especially one with several other packages in tow (e.g., MBESS), I either have to go through the get.packages() process multiple times until it finally finishes or make it IT's headache to do quick like the bunny for me. I can't always wait for IT.
I just went to the library folder (Windows XP) and deleted all fileXXXX folders. Reran the install an it is worked.
I had the same problem. Since the issue seems to be the antivirus blocking the transf of a downloaded file, I tried a different download method in the install.packages and it worked.
For example:
install.packages("stringr", method = "curl")
You must go into the properties of the R folder and change the security parameters. You can enable the option to write and modify for all users.
The error : "unable to move temporary installation" is basically arising due to any of the antivirus running on your system.
Try unzipping the downloaded file from the Temp folder into the default library path (you can get it by running .libPaths() in R session).
I'm using a MRAN and I was having so many versioning issues. Trying to work with tidyverse and ggplot2 and by upgrading to the latest version from Microsoft it solved all of my R-Studio versioning issues.
Version info:
Microsoft R Open 3.5.1
The enhanced R distribution from Microsoft
Default CRAN mirror snapshot taken on 2018-08-01.
Download Microsoft R Open 3.5.1

Resources