[R] Running R on read-only file system, without temporary directory

Gábor Csárdi csardi at rmki.kfki.hu
Sat Sep 5 08:55:02 CEST 2009


Thanks for all the answers. I have made some quick and dirty
modifications to make it start without a temporary directory and so
far it runs OK.

Obviously, I cannot do help(), example(), install.packages() and
Rprof() and maybe many more, but this is not an interactive machine,
but an Rserve server, so these are OK.

I will check the tempfile() and tempdir() calls to see what to expect.

Gabor

On Sat, Sep 5, 2009 at 2:40 AM, William Dunlap<wdunlap at tibco.com> wrote:
>> -----Original Message-----
>> From: r-help-bounces at r-project.org
>> [mailto:r-help-bounces at r-project.org] On Behalf Of Duncan Murdoch
>> Sent: Friday, September 04, 2009 5:05 PM
>> To: Gábor Csárdi
>> Cc: R mailing list
>> Subject: Re: [R] Running R on read-only file system,without
>> temporary directory
>>
>> On 04/09/2009 3:42 PM, Gábor Csárdi wrote:
>> > Dear All,
>> >
>> > I would like to do run R without having write permissions to any
>> > directory on the system. It seems that I need to modify the R source
>> > code for this, to make R start without creating a temporary
>> directory.
>> >
>> > So far, so good. But should I expect any more complications? Does R
>> > really need the temporary directory that much?
>>
>> Many R functions create temporary files in it.  (There are around 20
>> calls to tempfile() and another 20 to tempdir() in the base R
>> sources,
>> if my quick grep was right.  I've no idea how many calls
>> there are from
>> contributed packages.)  Would R work if these all failed?  I
>> don't know,
>> but I'd guess it wouldn't work very well.
>>
>> Duncan Murdoch
>
> On Linux R can do quite a bit without using R_SESSION_TMPDIR
> (which is where its temp files get made).  You can see if it can
> do enough for your needs by doing
>   Sys.chmod(Sys.getenv("R_SESSION_TMPDIR"), "0000")
> right after starting up.  E.g.,
>
>   > Sys.chmod(Sys.getenv("R_SESSION_TMPDIR"), "0000")
>   > 1:10
>    [1]  1  2  3  4  5  6  7  8  9 10
>   > names(cars)
>   [1] "speed" "dist"
>   > lm(dist~speed, data=cars)
>
>  Call:
>  lm(formula = dist ~ speed, data = cars)
>
>  Coefficients:
>  (Intercept)        speed
>      -17.579        3.932
>
>  > plot(.Last.value)
>  Hit <Return> to see next plot:
>  Hit <Return> to see next plot:
>  Hit <Return> to see next plot:
>  Hit <Return> to see next plot:
>  > help(plot)
>  Error in file(out, "wt") : cannot open the connection
>  In addition: Warning message:
>  In file(out, "wt") :
>    cannot open file '/tmp/RtmpPxKrY4/Rtxt327b23c6': Permission denied
>  > example(lm)
>  Error in file(out, "wt") : cannot open the connection
>  In addition: Warning message:
>  In file(out, "wt") :
>    cannot open file '/tmp/RtmpPxKrY4/Rex643c9869': Permission denied
>  > install.packages("ggplot2")
>  --- Please select a CRAN mirror for use in this session ---
>  Loading Tcl/Tk interface ... done
>  Error in install.packages("ggplot2") :
>    unable to create temporary directory '/tmp/RtmpPxKrY4/downloaded_packages'
>  In addition: Warning message:
>  In dir.create(tmpd) :
>    cannot create dir '/tmp/RtmpPxKrY4/downloaded_packages', reason 'Permission denied'
>
> Of couse, that doesn't catch things done during startup or temp files
> created outside of the R-standard directory.
>
> Bill Dunlap
> TIBCO Software Inc - Spotfire Division
> wdunlap tibco.com
>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>



-- 
Gabor Csardi <Gabor.Csardi at unil.ch>     UNIL DGM




More information about the R-help mailing list