[R] tempdir() does not respect TMPDIR

Jinsong Zhao j@zh@o @end|ng |rom ye@h@net
Sun Aug 30 01:30:27 CEST 2020


I read the help page, I don't understand it very well, since I set the 
environmental variable TMPDIR in .Renviron. What confused me is when 
double clicking the *.RData to launch R, the tempdir() does not respect 
the environmental variable TMPDIR, but launch R by double clicking Rgui 
icon does.

Best,
Jinsong

On 2020/8/30 0:36, Henrik Bengtsson wrote:
> It is too late to set TMPDIR in .Renviron.  It is one of the
> environment variables that has to be set prior to launching R.  From
> help("tempfile", package = "base"):
> 
> The environment variables TMPDIR, TMP and TEMP are checked in turn and
> the first found which points to a writable directory is used: if none
> succeeds ‘/tmp’ is used. The path should not contain spaces. **Note
> that setting any of these environment variables in the R session has
> no effect on tempdir(): the per-session temporary directory is created
> before the interpreter is started.**
> 
> /Henrik
> 
> On Sat, Aug 29, 2020 at 6:40 AM Jinsong Zhao <jszhao using yeah.net> wrote:
>>
>> Hi there,
>>
>> When I started R by double clicking on Rgui icon (I am on Windows), the
>> tempdir() returned the tmpdir in the directory I set in .Renviron. If I
>> started R by double clicking on a *.RData file, the tempdir() return the
>> tmpdir in the directory setting by Windows system. I don't know whether
>> it's designed.
>>
>>   > sessionInfo()
>> R version 4.0.2 (2020-06-22)
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>> Running under: Windows 10 x64 (build 18363)
>> ...
>>
>> Best,
>> Jinsong
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.



More information about the R-help mailing list