Why do I need to run find_rtools () before has_devel () = TRUE?

I try to follow the manual at http://adv-r.had.co.nz/Rcpp.html to understand Rcpp but I always need to run devtools::find_rtools() before any Rcpp function will work: If I doing

 library(devtools) library(Rcpp) has_devel() # Error: Command failed(1) # Example from http://adv-r.had.co.nz/Rcpp.html add <- cppFunction('int add(int x, int y, int z) { int sum = x + y + z; return sum; }') 

I get an error and Rstudio offers me to install additional build tools (but nothing happens when I say yes). It seems that the make command does not work, but system("where make") indicates the path that is in my PATH. When i do

 find_rtools() # True has_devel() # True # Try the example again add <- cppFunction('int add(int x, int y, int z) { int sum = x + y + z; return sum; }') # Now works add(1,2,3) # 6 

both devtools and rcpp seem happy. Why is this and how can I fix it?

Here is the beginning of my PATH

 path <- get_path() head(path, 8) [1] "F:\\Software\\R-3.3.0\\bin\\x64" "F:\\Software\\Rtools\\bin" [3] "F:\\Software\\Rtools\\gcc-4.6.3\\bin" "F:\\Software\\Python 3\\Scripts\\" [5] "F:\\Software\\Python 3\\" "F:\\Software\\Rtools\\bin" [7] "F:\\Software\\Rtools\\gcc-4.6.3\\bin" "C:\\Program Files (x86)\\Intel\\iCLS Client\\" 
0
r rcpp devtools
source share
1 answer

Basically, you did not set the installation location of rtools in the system PATH variable. Thus, devtools::find_rtools() scans the registry and adds it . Adding is valid only for the active session.

Now devtools::has_devel() is a very simple assembly and C ++ file link . Thus, running devtools::has_devel() without the necessary environment (for example, the actual installation of rtools) will fail. In this case, the environment is simply not configured correctly, since the system PATH variable has not been changed.

Verify that the following is specified in the system path variable:

C:\Rtools\bin and C:\Rtools\gcc-4.6.3\bin

Check for a clean R session:

 Sys.getenv("PATH") 
+2
source share

All Articles