[R] Problem with R CMD BATCH on R-2.5.0 due to Sys.unsetenv not available
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon May 14 18:38:02 CEST 2007
On Mon, 14 May 2007, Peter Dalgaard wrote:
> Simon Penel wrote:
>> Hello,
>>
>> I am working on an unix SunOS machine ( sun4u sparc) and since the last
>> release of R -R version 2.5.0 (2007-04-23) - ,
>> I have got troubles during the execution of batch command.
>>
>>
>> For example with the instruction file multic.in
>> >cat multic.in
>> install.packages("multic","/bge/penel/R_install/R_2.5.0/lib/R/library",repos="http://cran.at.r-project.org")
>>
>>
>> When I use the BATCH command, I get an error :
>>
>> >R_2.5.0/bin/R CMD BATCH multic.in
>>
>> creates the multic.in.Rout file :
>>
>> >cat multic.in.Rout
>> Error in Sys.unsetenv("R_BATCH") : 'Sys.unsetenv' is not available on
>> this system
>> Execution halted
>>
>>
>> Effectiveley, Sys.unsetenv is not available on unix
>> When running R :
>> > Sys.unsetenv("toto")
>> Error in Sys.unsetenv("toto") : 'Sys.unsetenv' is not available on this
>> system
>>
>>
>> Does that mean that it is not possible anymore to use R CMD BATCH on
>> unix OS ?
>>
> Hmm, if so, nobody did the platform testing sufficiently well...
My 'SunOS machine' (Solaris 10) has it working. What version of SunOS was
this? Sys.unsetenv is using POSIX API functions, so any reasonably modern
Unix should support it.
> The code in question seems to be at the end of
>
> src/library/profile/Common.R
>
> which ends up in the system-wide
>
> library/base/R/Rprofile
>
> ----------------------------------
>
> if(Sys.getenv("R_BATCH") != "") {
> .Last.sys <- function()
> {
> cat("> proc.time()\n")
> print(proc.time())
> }
> ## avoid passing on to spawned R processes
> Sys.unsetenv("R_BATCH")
> }
>
>
>
>> This is very recent, since it was working fine with the R-patched
>> version :R version 2.5.0 Under development (unstable) (2007-03-18 r40854)
Hmm, that would have to be R-devel.
> Yes, svn praise has this:
>
> 40621 ripley if(Sys.getenv("R_BATCH") != "") {
> 40621 ripley .Last.sys <- function()
> 40621 ripley {
> 40621 ripley cat("> proc.time()\n")
> 40621 ripley print(proc.time())
> 40621 ripley }
> 40972 ripley ## avoid passing on to spawned R processes
> 40972 ripley Sys.unsetenv("R_BATCH")
> 40621 ripley }
and 40971 (which is what it says in the trunk) was on 2007-03-30, so
at the beginning of the test process for 2.5.0.
> Does Sys.setenv work? If so, you might replace the offending line by
>
> Sys.setenv("")
>
> (or remove it entirely and avoid spawning R processes....)
The internals of Sys.unsetenv() try several possibilities. But as the
help page says
Not all systems need support 'Sys.setenv' (although all known
current platforms do) nor 'Sys.unsetenv'.
Using Sys.setenv(R_BATCH="") might be more portable.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list