Fatal Error: "R_TempDir" contains spaces (again)

This is a repeat of a question that was asked here before but didn't get any answers. I have a student whose Windows User ID contains a space (think "Amelia McNamara") and they are getting this temp directory error when they try to launch R/RStudio. We've tried a lot of the ideas suggested on the web, including:

None of these have changed the error. Any other ideas? A couple of things I have thought of:

  • I didn't have the student restart their computer. Do we need to do that for these changes to take effect?
  • When we look at the list of environment variables in the Windows interface, the one we created is at the very bottom under TMP and TEMP. I saw someone say that the various temp directories are tried "in order" and wasn't sure if that was in the order of the list there. It didn't seem possible to reorder the list.
  • Where do we need to worry about the direction of slashes, and where don't we? For the environment variables, we used C:\Temp but for the Renviron.site we used TMP=C:/Temp TEMP=C:/Temp TMPDIR=C:/Temp as suggested. I think that's the way things usually work in R, but just want to make sure it's not something silly.

Other ideas? Having the student change their user ID may or may not help, because all those paths and directories have already been created.

Can you show the output of Sys.getenv()? that could give us a clue

Hi @AmeliaMN,

This part of help(tempfile) gives the answer:

"By default, tmpdir will be the directory given by tempdir().
This will be a subdirectory of the per-session temporary directory found by the
following rule when the R session is started. 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 the value of R_USER (see Rconsole) is used.
If the path to the directory contains a space in any of the components, the path
returned will use the shortnames version of the path. 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."

Looks like there is no alternative but to create a new Windows user account name
with no spaces (using underscore in place of any space should be fine). This is certainly
an unfortunate "clash" between what's permitted on Windows compared to R.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.