-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Providing option to override temp location would be a great enhancement #172
Comments
That seems reasonable to me. OTOH the advantage of an environment variable is that it is inherited in subprocesses by default, whereas an option will not be set in a subprocess. If you set an option in Here is a workaround to change the temporary directory from within the session. It works from R 3.5: > tempdir()
[1] "/var/folders/59/0gkmw1yj2w7bf2dfc3jznv5w0000gn/T//RtmpUI1O6O"
> Sys.setenv(TMPDIR = "/Users/gaborcsardi")
> unlink(tempdir(), recursive = TRUE)
> tempdir(check = TRUE)
[1] "/Users/gaborcsardi/RtmpXaziuR"
> tempdir()
[1] "/Users/gaborcsardi/RtmpXaziuR" |
@scottporter So, how about setting |
Just noticed the response. I'll give the workaround a try and give feedback. |
At least on Linux, changing the temp location the way you've laid out doesn't work (I tried R 3.4.1 and R 3.5.3) Here is the log from R 3.5.3.
Setting the environment variable in the session is too late for the tempdir... it's already been specified. I also tried running my process to see if, even though it doesn't reflect properly here, if that environment variable would get picked up by the callr sessions... but no such luck. So, the only workaround that I have found is adding the environment variable to my ~.Renviron file. |
You have to remove the old temp dir first, like here: #172 (comment) But setting it in EDIT: now you edited and added the > tempdir()
[1] "/tmp/RtmpEpCIDc"
> newtmp <- "~/tmp/rcall"
> dir.create(newtmp, recursive = TRUE)
> Sys.setenv(TMPDIR = tools::file_path_as_absolute(newtmp))
> unlink(tempdir(), recursive = TRUE)
> tempdir(check=TRUE)
[1] "/root/tmp/rcall/RtmpmGFIia" |
My edit was because I tried it again, adding the unlink, and got the same result. However, I tried your code above, and it worked. I'm not sure what I did wrong last time. Thanks.
|
I'm guessing that last time I accidentally ran it on R 3.4.1. I have both that and R 3.5.3 installed on my server cluster. I don't think this workaround works for R 3.4.1, which is why I ended up getting so confused. |
There is no `tempdir(check = TRUE)` on R 3.4.x AFAICT, so it cannot work
there.
…On Wed, Dec 23, 2020 at 7:54 PM scottporter ***@***.***> wrote:
I'm guessing that last time I accidentally ran it on R 3.4.1. I have both
that and R 3.5.3 installed on my server cluster. I don't think this
workaround works for R 3.4.1, which is why I ended up getting so confused.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#172 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFBGQDC3PCEBWEHUWXZH6LSWJDHJANCNFSM4ST566DA>
.
|
Thanks again. |
Since there is an adequate workaround for this, I am going to close it. |
Apologies for posting on an old-ish issue, but I thought it was most relevant here. I've tried this workaround for a problem I'm having where the R When I try to recreate a tempdir using
Deleting the temp folder causes
Now recreate a
Honestly, I wish I knew what how the tempdirs were being deleted and how to fix that, but the I can't get the problem to reliably occur. It seems like relying on |
Can you set the |
Yes; in my application, this is unsufficient to avoid the error. Something (I think maybe when a child process exits) is deleting the folder while the main process is running, I think. In my
and sometimes, when
and But this is annoying because I can't replicate it reliably enough to pin down what is deleting the tempdir. That's why it would be useful to use a folder that doesn't rely on |
Our server cluster is set up so each server has a small /tmp partition. When I need to save out large temporary files, I do so by manually specifying another partition when I create the temporary files. I don't see any facility in callr for specifying a different location other than the one returned by
tempdir()
. If I understand correctly, I would have to start R by specifying a different location either in .Renviron or using an environment variable. Our R setup works fine for our regular use, but I started testing out callr using future.callr and quickly brought a server to its knees and incurred the wrath of our sys admins. With some convincing I can get the setup of our cluster changed, but it would be nice to have control over the temp location callr uses from inside R (instead of having to set it before R starts). However, not sure if that's even possible based on how each callr session starts.The text was updated successfully, but these errors were encountered: