1

I have completely uninstalled R, RStudio, and RTools and removed all folders (as described here); then re-installed R (4.0.4), RTools (4.0 x86), and RStudio (1.4.1106). I have added the RTools folder to the path (Sys.getenv("PATH") # [1] "$C:\\rtools40\\usr\\bin;....") but the problem persists - 'make' is empty, although C:\rtools40\usr\bin\make.exe exists:

> Sys.which("make")
make 
  "" 

Can someone help me? (This question didn't help, since my PATH variable contains the RTools folder already.)

Thanks a lot in advance! :)

r2evans
  • 141,215
  • 6
  • 77
  • 149
Ivo
  • 3,890
  • 5
  • 22
  • 53
  • 2
    Is there a reason the `PATH` starts with `$C:` instead of just `C:`? – r2evans Feb 26 '21 at 13:57
  • 1
    Test this with `Sys.setenv(PATH=gsub("^\\$", "", Sys.getenv("PATH")))`, and then `Sys.which("make")`. If that works, make sure you fix where that mistake is entered (such as the *Environment Variables* control for windows). – r2evans Feb 26 '21 at 14:00
  • Additionally, how do I set the path permanently? It vanishes after I restart R (despite appending the Rtools path to PATH variable - `Sys.setenv(PATH = paste(old_path, "C:\\rtools40\\usr\\bin\\", sep = ";"))` – The Great Aug 04 '21 at 07:45
  • @r2evans - can help me please? While the above command sets the Rtools path to the path variable, it vanishes after I restart the RGUI – The Great Aug 04 '21 at 08:08
  • Since this works, I suggested that you fix it in a more proper place, wherever the environment variables are set for your OS. If windows, go to *Settings* (windows, not R) and look for *Environment Variables*and modify the path there. – r2evans Aug 04 '21 at 08:44

2 Answers2

1

For posterity: the problem was that the "$" doesn't belong in the path.

Thanks to @r2evans for the solution - Sys.setenv(PATH=gsub("^\\$", "", Sys.getenv("PATH"))) did the trick.

Ivo
  • 3,890
  • 5
  • 22
  • 53
0

For me the solution proposed here worked for a single session, then I had to add the paths permanently in the environmental variables settings as suggested by @r2evans.

This is the solution for a single session:

path <- Sys.getenv("PATH")
path <- c("C:\\RBuildTools\\3.3\\bin", "C:\\RBuildTools\\3.3\\gcc-4.6.3\\bin", path) 
#Remember to substitute the two paths with your actual paths.
path <- paste(path,collapse=";")

#Then run
Sys.setenv(PATH=path)
Sys.which("make")

In both the temporary and permanent solution I had to include the paths at the beginning of PATH, otherwise they were not recognized, but I don't know why.

jmarkov
  • 191
  • 9