[R] Solve for "Please set TMPDIR to a valid temporary directory"

aedin culhane aedin.culhane at ucd.ie
Mon May 10 16:09:05 CEST 2004


Dear R Help,
My apologies if this is widely known, but I didn't find this in the R 
archives. 

I am running WinXP pro and R 1.90.  Rcmd build or check fails with the 
error: "Please set TMPDIR to a valid temporary directory"

$TMPDIR is set to $TMPDIR or C:/TEMP in share\perl\R\Var.pm.  TMPDIR or 
c:\temp do not exist on WinXP on my laptop. I have C:\WUTemp and the 
env variables $TMP and $TEMP are set (..Is this normal?).  

The two work arounds I found are to create a C:\temp directory, or 
include $TMP or $TEMP in Var.pm. I did the latter, and it works for me. 
I include the fix below.


if($OSTYPE eq "windows"){
    ## DON'T add R_HOME/bin here: it might contain spaces and will not
    ## work using system() under Windows 98. 
    $R_EXE = "Rterm.exe";
    $R_CMD = "Rcmd.exe";
    getenv("TMPDIR", "TMP", "TEMP", "C:/TEMP"); # Edited to include TMP 
and TEMP
    print "tmpdir is $TMPDIR\n";   # Edited to include print
    if (-d $TMPDIR) {
	$TMPDIR = Win32::GetShortPathName($TMPDIR) if $TMPDIR =~ / /;
	$TMPDIR =~ s+\\+/+g;  ## ensure forward slashes only
    } else {
	$TMPDIR = "" 
    }
}


> version
platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    1
minor    9.0
year     2004
month    04
day      12
language R


Regards
Aedin




More information about the R-help mailing list