change or set /tmp directory for shiny app

Dear all,

I have been running shiny app which produces the output files to the default /tmp directory. Due to the small disk size of '/tmp' directory i wanted to change to a different location '/mnt/tmp'. To achieve this i have added the below variables to Rprofile and Renviron files:









Now, i have tested by opening R in the terminal which worked as expected.

> tempdir()[1] "/mnt/tmp/RtmpbQMrhQ"

However, the problem is with shiny app, the application could not be launched with the below error:

==> /var/log/shiny-server/webgqt-shiny-20190628-074640-33053.log <==Fatal error: cannot create 'R_TempDir'

Below are the access rights for the /mnt/tmp:

drwxrwxrwx 2 shiny shiny 4.0K Jun 28 07:47 tmp

Could someone help, what has been wrong here.

I have also posted it here:!topic/shiny-discuss/-gxmVWrwb5M

Please follow our cross posting policy, you are not supposed to just dump links to other FAQ site

I have modified the OP. I hope this is valid way for cross-posting.

  1. Only the .Renviron is needed
  2. Try switching to the shiny user (sudo su - shiny) and launching R, that should give you the ability to iterate directly from the command line
  3. If that's what you've already done, are you sure your app is running as the shiny user?

The error Fatal error: cannot create 'R_TempDir' is solved now by changing the /tmp write permissions. However, the main issue which is to create tempdir in /mnt/tmp instead of /tmp still persists.

I tried as root, shiny and ubunutu user. When it tried as shiny user or root, it creates tempdir at /tmp instead of at /mnt/tmp, below is the output:

$ sudo su - shiny
$ R
> tempdir()
[1] "/tmp/Rtmp1THYua"

##When tried as root user it creates tempdir at /tmp instead of at /mnt/tmp###

$ sudo su - root
root@webgqt:~# R
> tempdir()
[1] "/tmp/RtmpP3WO2k"

###As ubuntu user it works as expected###

$ sudo su - ubuntu
ubuntu@webgqt$ R
> tempdir()
[1] "/mnt/tmp/RtmpdEUXLT"

Here are the permissions for /tmp and /mnt/tmp:

$ ls -ld /tmp
drwxrwxrwx 5 root root 12288 Jul 3 17:05 /tmp

$ ls -ld /mnt/tmp/
drwxrwxrwx 2 root root 4096 Jul 3 17:05 /mnt/tmp/

How can i change the tempdir to /mnt/tmp?

Then that means the .Renviron is in the wrong place. When you said ~/.Renviron did you mean ~ being the ubuntu user's home for? Because that won't affect the shiny or root users. Instead you need to use the system wide (I'm writing this on my phone so please forgive me for not tracking down that location for you, but you should be able to Google around for it), or put .Renviron directly in the app dir (only if you want to change just the one app and not all apps).

1 Like

Thank you. is in /etc/R/. And adding the TMPDIR,TMP,TEMP variable did the trick.

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