[Rd] R CMD INSTALL writes to stderr
Simon Urbanek
simon.urbanek at r-project.org
Tue Oct 11 03:23:47 CEST 2011
On Oct 10, 2011, at 8:48 PM, Mark Cowley wrote:
> Dear list,
> (this is a follow up from a previous query)
>
> Why does R CMD INSTALL write most of its messages to stderr? If it wrote to stdout, then we could capture its output within an R session when calling
> sink("stdout.txt", type="output")
> install.packages("MASS", type="source")
> sink()
>
> As it stands, the stderr messages can't be captured via sink/capture.output/suppressMessages within an R session. Interestingly, the make output goes to stdout, but the R messages go to stderr:
>
> # the 'make' output goes to stdout
> $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz 2>/dev/null
> gcc-4.2 -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -I/usr/local/include -fPIC -g -O2 -c MASS.c -o MASS.o
> gcc-4.2 -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -I/usr/local/include -fPIC -g -O2 -c lqs.c -o lqs.o
> gcc-4.2 -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o MASS.so MASS.o lqs.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
> gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/local/include -fPIC -g -O2 -c MASS.c -o MASS.o
> gcc-4.2 -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/local/include -fPIC -g -O2 -c lqs.c -o lqs.o
> gcc-4.2 -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o MASS.so MASS.o lqs.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
>
> # the R CMD INSTALL output goes to stderr
> $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz >/dev/null
> * installing *source* package ŒMASS‚ ...
> ** libs
> *** arch - i386
> installing to /private/tmp/MASS/libs/i386
> *** arch - x86_64
> installing to /private/tmp/MASS/libs/x86_64
> ** R
> ** data
> ** moving datasets to lazyload DB
> ** inst
> ** preparing package for lazy loading
> ** help
> *** installing help indices
> ** building package indices ...
> ** testing if installed package can be loaded
>
> * DONE (MASS)
>
> $ R --vanilla CMD INSTALL -l /tmp MASS_7.3-14.tar.gz &>/dev/null
> # no output
>
> Why do I care? i'm writing some software which uses R behind the scenes, and would like to suppress the messages that are produced by install.packages() when R libraries are being installed.
>
> So, will it be possible for R CMD INSTALL output be written to stdout in the future?
>
It can simply with 2>&1
I agree that this doesn't help you with install.packages directly. There are various degrees of ugliness that you can apply - ranging from using INSTALL_opts to force routing to stdout, to using your own system() front-end to handle the details yourself.
Why you don't simply use a variation of system("R -e 'install.packages(...)'", ...) where you have full control over the routing and yet sill use install.packages? That is generally how custom installers do this ... It sort of seems what you are trying to do anyway since you don't want the internal R output ...
Cheers,
Simon
> kind regards,
> Mark
>
>
> -----------------------------------------------------
> Mark Cowley, PhD
>
> Pancreatic Cancer Program | Peter Wills Bioinformatics Centre
> Garvan Institute of Medical Research, Sydney, Australia
> -----------------------------------------------------
>
> sessionInfo()
> R version 2.13.1 (2011-07-08)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>
> locale:
> [1] en_AU.UTF-8/en_AU.UTF-8/C/C/en_AU.UTF-8/en_AU.UTF-8
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list