Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Temporary name too long" error that appears unexpectedly using Rnotebook

Tags:

r

rnotebook

While working with rnotebook I get the following error getting the output of a linear regression model via broom.

This is a dummy example of what I encounter:

    N <- 100
a <- rnorm(N)
b <- a + rnorm(N)
df1 <- data.frame(a, b)

lModel <- lm(b ~ a, df1)

summary(lModel)

Then if I want to get the output of tidy(lModel) I get the error:

Error in tempfile(pattern = "_rs_rdf_", tmpdir = outputFolder, fileext = ".rdf") : temporary name too long

The thing is that I have used the tidy() function from broom not long before and got the output. I wonder what may be the issue, and how it can be fixed.

This is the traceback of the error above:

Error in tempfile(pattern = "_rs_rdf_", tmpdir = outputFolder, fileext = ".rdf") : temporary name too long
4.
tempfile(pattern = "_rs_rdf_", tmpdir = outputFolder, fileext = ".rdf")
3.
overridePrint(o$x, o$options, o$className, o$nRow, o$nCol)
2.
print.data.frame(x)
1.
function (x, ...) UseMethod("print")(x)

Thanks a lot in advance.

like image 830
ogorodriguez Avatar asked Jan 03 '23 01:01

ogorodriguez


1 Answers

This error occurs on Windows systems when directories are nested too many levels in. The Windows API has a maximum path length of 260 characters.

Maximum Path Length Limitation In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string" where "" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)

This is pretty easy to avoid. Just adjust your working directory, or the structure where you're saving your tempfile. Either your file name is too long, or your directory is nested too deeply so the path is exceeding Windows' path limits.

As an aside, on Unix systems this the max path significantly longer but there is a max file name length of 255 chars.

like image 110
dshkol Avatar answered Jan 05 '23 16:01

dshkol