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:
~/.Rprofile
TMPDIR="/mnt/tmp"
TMP="/mnt/tmp"
TEMP="/mnt/tmp"
~/.Renviron
TMPDIR="/mnt/tmp"
TMP="/mnt/tmp"
TEMP="/mnt/tmp"
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:
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"
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 Renviron.site (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).