Error after running build() to create R package in

2019-01-28 12:56发布

问题:

I am trying to build an R package using RStudio on Windows 8 Pro. When I attempt to build the package by running build() I get the error:

"C:/Program Files/R/R-30~1.2/bin/x64/R" --vanilla CMD build "H:\File Assembly\FileAssembler"  \
--no-manual --no-resave-data 

'C:\Program' is not recognized as an internal or external command, operable program or batch file.
Error: Command failed (1)

I already have MiKTEX installed and I have checked this by:

Sys.which("pdflatex") 
                                                        pdflatex
"C:\\Program Files (x86)\\MIKTEX~1.9\\miktex\\bin\\pdflatex.exe" 

The R version I am using is: R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"

Loading library(devtools) and running find_rtools(T) gives:

find_rtools(T)  
Scanning path...
ls : c:\Rtools\bin\ls.exe 
gcc: c:\Rtools\GCC-46~1.3\bin\gcc.exe 
VERSION.txt
Rtools version 3.1.0.1942 
Version: 3.1 
[1] TRUE

In addition, the path for rtools exes are:

Sys.which("ls.exe")
                   ls.exe 
"c:\\Rtools\\bin\\ls.exe" 

Sys.which("gcc.exe")
                               gcc.exe 
"c:\\Rtools\\GCC-46~1.3\\bin\\gcc.exe" 

And checking the path in R:

Sys.getenv('PATH')
[1] "C:\\Program Files\\R\\R-3.0.2\\bin\\x64;c:\\Rtools\\bin;c:\\Rtools\\gcc-4.6.3\\bin;……other paths…………;C:\\Program Files (x86)\\MiKTeX 2.9\\miktex\\bin\\"

I would really appreciate help with identifying what I have missed out.

回答1:

This is a common error caused by a space in the install location path (C:\Program Files). The solution, and the official R recommendation is that you never install R in a location with spaces in it on Windows if you want to be able to install packages from source.

from http://cran.r-project.org/bin/windows/rw-FAQ.html#How-do-I-install-R-for-Windows_003f:

If you want to be able to build packages from sources, we recommend that you choose an installation path not containing spaces.



回答2:

I had the same problem.

Took some time to find that Rcmd.exe was removed by the Kaspersky antivirus.

once I detected that it was easy to fix.

good luck

Offer