[Rd] R 3.0, Rtools3.0,l Windows7 64-bit, and permission agony
Gabor Grothendieck
ggrothendieck at gmail.com
Mon Apr 22 01:04:11 CEST 2013
On Sun, Apr 21, 2013 at 6:17 PM, Henrik Bengtsson <hb at biostat.ucsf.edu> wrote:
> I (as well) keep a specific Rsetup.bat file for launching Windows
> cmd.exe with the proper PATH etc setup for build R packages etc. It's
> only after this thread I gave it a second thought; you can indeed
> temporarily set the PATH via ~/.Rprofile or ~/.Renviron, which *are*
> processed at the very beginning when calling 'R CMD ...'.
>
> EXAMPLE WITH .Rprofile:
>
> ## ~/.Rprofile (e.g. C:/User/foo/.Rprofile):
> path <- unlist(strsplit(Sys.getenv("PATH"), ";"));
> path <- c("C:\\Rtools\\bin", "C:\\Rtools\\gcc-4.6.3\\bin", path);
> Sys.setenv("PATH"=paste(unique(path), collapse=";"));
>
> ## DISABLED:
> x:\> R --no-init-file CMD INSTALL matrixStats_0.6.2.tar.gz
> * installing to library 'C:/Users/hb/R/win-library/3.0'
> * installing *source* package 'matrixStats' ...
> ** libs
> *** arch - i386
> ERROR: compilation failed for package 'matrixStats'
> * removing 'C:/Users/hb/R/win-library/3.0/matrixStats'
>
> ## ENABLED:
> x:\> R CMD INSTALL matrixStats_0.6.2.tar.gz
> * installing to library 'C:/Users/hb/R/win-library/3.0'
> * installing *source* package 'matrixStats' ...
> ** libs
> *** arch - i386
> gcc -m32 -I"C:/PROGRA~1/R/R-3.0.0patched/include" -DNDEBUG [...]
> [...]
> * DONE (matrixStats)
>
>
> EXAMPLE WITH .Renviron:
> ## ~/.Renviron (e.g. C:/User/foo/.Renviron):
> # Backslashes are preserved iff put within quotes
> PATH="C:\Rtools\bin;C:\Rtools\gcc-4.6.3\bin;${PATH}"
>
> x:\> R --no-environ CMD INSTALL matrixStats_0.6.2.tar.gz
> => fails
>
> x:\> R CMD INSTALL matrixStats_0.6.2.tar.gz
> => works
>
> As long as R is on the PATH, the above either of the approaches
> removes the need to add Rtools to the PATH via a BAT file and it won't
> clutter up your PATH. This begs the question (as somewhat already
> proposed), instead of users/developers doing this manually, would it
> be possible to have 'R CMD ...' to locate add Rtools to the PATH
> internally. That would certainly lower the barriers for newcomers to
> install packages from source that need compilation. Obviously, this
> doesn't make the tools (e.g. make) in Rtools available outside of R,
> it does not allow you to build R itself from source, but it does cover
> the very common use cases of calling 'R CMD build/INSTALL/check/...'.
>
> /Henrik
>
> PS. Hadley, is this what you meant when you wrote "Better solutions
> (e.g. Rstudio and devtools) temporarily set the path on when you're
> calling R CMD *.", or those approaches are only when you call 'R CMD'
> from the R prompt? I believe the latter, but I just want to make sure
> I didn't miss something.
That seems like a reasonable approach although the code shown does
entail more setup and ongoing maintenance by the user than R.bat which
does not require that the user edit any files and additionally locates
R itself and has many other features. Also, because R.bat locates R
itself it can be useful even if you are not doing development. On the
other hand if you are looking to do development strictly from within R
then devtools is already developed.
More information about the R-devel
mailing list