[R] Problem with R CMD BATCH on R-2.5.0 due to Sys.unsetenv not available
Simon Penel
penel at biomserv.univ-lyon1.fr
Mon May 14 19:22:03 CEST 2007
Prof Brian Ripley a écrit :
> 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.
This a quiet old version: 5.9
>
>> 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.
>
Sys.setenv(R_BATCH="") works ok
I will try that
thanks again for your help,
Simon
--
Simon Penel
Laboratoire de Biometrie et Biologie Evolutive
Bat 711 - CNRS UMR 5558 - Universite Lyon 1
43 bd du 11 novembre 1918 69622 Villeurbanne Cedex
Tel: 04 72 43 29 04 Fax: 04 72 43 13 88
http://pbil.univ-lyon1.fr/members/penel
More information about the R-help
mailing list