[Rd] Bug report: R.home() cause package Rcpp failed executing sourceCpp, similar bug are labeled "BUG 16660" since 2016 and here I could provide a solution that tested in my laptop.

qweytr1 m@ili@g off m@il@ustc@edu@c@ qweytr1 m@ili@g off m@il@ustc@edu@c@
Fri Dec 21 19:34:54 CET 2018


https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16660
Here is the bug, which R.home may generate a path contains a whitespace.


this will cause Rcpp failed executing sourceCpp


> sourceCpp("b:/2018-12-14/src/18020/MCMC.cpp")
Error in system(cmd, intern = !showOutput) : 'D:/Program' not found
Error in system(cmd, ignore.stderr = TRUE, intern = TRUE) :
  'D:/Program' not found



Code is tested in both R 3.5.1 and Microsoft R Open 3.5.1.


I find a temp solution, is to copy such words into Rprofile:


unlockBinding("R.home", baseenv())
utils::assignInNamespace("R.home",function (component = "home")
{
    rh <- .Internal(R.home())
    paste0('"',switch(component, home = rh, bin = if (.Platform$OS.type ==
        "windows" && nzchar(p <- .Platform$r_arch)) file.path(rh,
        component, p) else file.path(rh, component), share = if (nzchar(p <- Sys.getenv("R_SHARE_DIR"))) p else file.path(rh,
        component), doc = if (nzchar(p <- Sys.getenv("R_DOC_DIR"))) p else file.path(rh,
        component), include = if (nzchar(p <- Sys.getenv("R_INCLUDE_DIR"))) p else file.path(rh,
        component), modules = if (nzchar(p <- .Platform$r_arch)) file.path(rh,
        component, p) else file.path(rh, component), file.path(rh,
        component)),'"')
}, ns="base", envir=baseenv())
lockBinding("R.home", baseenv())


Actually, calling "D:/Program Files/R/R Open/bin/x64"/R is same to calling "D:/Program Files/R/R Open/bin/x64/R"


it shows that we could use quote to quote the whitespaces.


(although the code seems a little bit ugly)



               _                          
platform       x86_64-w64-mingw32         
arch           x86_64                     
os             mingw32                    
system         x86_64, mingw32            
status                                    
major          3                          
minor          5.1                        
year           2018                       
month          07                         
day            02                         
svn rev        74947                      
language       R                          
version.string R version 3.5.1 (2018-07-02)
nickname       Feather Spray      







	[[alternative HTML version deleted]]



More information about the R-devel mailing list