27

I am relatively new to R/RStudio. I was successfully able to install packages until today. Each time I try to install a package, I receive the following error:

WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding: https://cran.rstudio.com/bin/windows/Rtools/ Installing package into ‘C:/Users/my. Name/Documents/R/win-library/3.6’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/openintro_1.7.1.zip' Content type 'application/zip' length 3136068 bytes (3.0 MB) downloaded 3.0 MB

Rtools is already installed on my machine, so I'm not sure why it's not being recognized.

I have tried un-installing and re-installing rtools but can't seem to resolve the issue. Any insight here would be greatly appreciated!

Phil
  • 7,287
  • 3
  • 36
  • 66
slp
  • 271
  • 1
  • 3
  • 4
  • 1
    Top of my head : bad version of rtools, bad path environment variable on windows, bad directory location for installation, not the correct rights to access the rtools directory, etc. Check all these – Poutrathor Nov 24 '19 at 22:19
  • Thank you. How am I able to check these? If it's one of the issues you've described, how can I resolve? RTools installed under the path: C:\Rtools – slp Nov 24 '19 at 22:23
  • Read this thread for more information about R/Rtools inner workings. https://github.com/rstudio/rstudio/issues/3563 Check your windows PATH variable (google it if you need) and add to it as described in R documentation. Rights in windows are often resolved by starting RStudio as Administrator. And download only the last versions of Rstudio and Rtools. Also, you should be able to find more logs somewhere, google to find how to start Rstudio in verbose mode or something similar. Good luck with your struggle. – Poutrathor Nov 24 '19 at 22:41
  • To check versions if Rtools is in C:\Rtools then from within R `file.show("C:/Rtools/version.txt")` will show its version and typing `R.version.string` will show the R version. the table at the web site https://cran.r-project.org/bin/windows/Rtools/ will show what version of Rtools you need for a given R version. Also again assuming Rtools is at C:\Rtools check if C:\Rtools\bin, C:\Rtools\mingw_32\bin and C:\Rtools\mingw_64\bin are on your Windows PATH. – G. Grothendieck Nov 25 '19 at 00:43
  • What do you get when you type `devtools::find_rtools()`? And do you get this warning when you try to install the package `abind` for example, which does not require Rtools ? – Stéphane Laurent Nov 25 '19 at 06:24
  • 3
    @slp did you manage to resolve your problem with Rtools ? – Poutrathor Nov 27 '19 at 17:41
  • 2
    I solved this finally by re-installing R. – Fuhrmanator May 28 '21 at 18:00
  • 1
    Add Rtools path to System Environment variable – Nad Pat Sep 04 '21 at 10:28
  • 90% of the time this is a path issue. It's easy to not choose the "modify my path" option when installing rtools. – Dason Dec 23 '21 at 22:26

2 Answers2

10

The message indicates RTools isn't installed properly. Download and install it like so:

  1. Go here
  2. Download rtools
  3. Find the file that just downloaded
  4. Double click on it to start installation
  5. Close and reopen RStudio
  6. Everything should work now!

A nice 2-minute video explainer can be found here.

Why is RTools necessary in the first place?

Rtools is a collection of software you need to be able to call R from the command line on Windows. You need to be able to call R from the command line to build and install packages from source code. Most packages will also require the program pdflatex.

If you have installation problems

  • Re-install R. Try to stick to the default installation settings if possible. Don't forget to close all current R sessions before reinstalling, then start a new R session and see if it works as expected. If not, try downloading and installing Rtools as outlined at the top of this answer; hopefully it installs as expected now.
  • Make sure your anti-virus software isn't preventing it being installed. Anti virus software can sometimes mistake it for something harmful and quarantine it.
  • When reinstalling R, or when installing Rtools manually, be careful to look for any indication that you do not have write permissions to the drive you're installing to. If you don't have permission to install certain things, that may be what's causing Rtools to not install correctly. This is more likely to happen if there are multiple users on your Windows computer, or if your organisation has strict policies about what can be installed. To look into this, figure out where Rtools is being installed to, and ensure you have the ability to write to that folder.
stevec
  • 41,291
  • 27
  • 223
  • 311
0

if your os is windows, you should install rtool to create a building env for some R packages.

full stack for install R Rstudio Rtool .

you can get answer from this video https://www.bilibili.com/video/BV1Mv411u7Cm?spm_id_from=333.999.0.0

yuanzz
  • 1,359
  • 12
  • 15