Trouble writing files on shiny-server

7,814 views
Skip to first unread message

bkj...@gmail.com

unread,
Jun 18, 2013, 8:02:07 PM6/18/13
to shiny-...@googlegroups.com
I'm running shiny server on EC2 in Ubuntu.  The app starts up normally, but if I try to use write.csv to write a file to /var/shiny-server/www/, I get the following error message:

Listening on port 38308 Warning in file(file, ifelse(append, "a", "w")) : cannot open file '/var/shiny-server/www/shiny_test/time.csv': Permission denied Error in file(file, ifelse(append, "a", "w")) : cannot open the connection

I don't know much about setting up servers, so this may be a relatively simple fix regarding permissions. I saw on another thread that I might have to make the server "root", but I don't know how to do that. Does anyone have any idea as to what I'm doing wrong?

FYI I followed the step-by-step installation instructions on the shiny-server page, so everything is (hopefully) set up as you would expect.

Thanks,
Ben

Joe Cheng

unread,
Jun 19, 2013, 12:30:51 AM6/19/13
to shiny-...@googlegroups.com
This is the correct default behavior; you generally want your R process to be running under a fairly restricted set of permissions, in case there is a security hole in your code (or in Shiny) an attacker won't be able to modify anything. However, if you do need to make modifications then you can change the config to allow that.

In this case, I'd create a subdirectory of your app dir (shiny_test) for the "shiny" user to write to:

# Create the directory
sudo mkdir /var/shiny-server/www/shiny_test/work
# Make shiny the owner of the directory
sudo chown shiny:shiny /var/shiny-server/www/shiny_test/work

Then change the path you pass to write.csv to be "work/time.csv" instead of "time.csv".




--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

bkj...@gmail.com

unread,
Jun 19, 2013, 8:50:43 AM6/19/13
to shiny-...@googlegroups.com
OK - I'll try this later today and let you know if I have further problems.  Sounds like it will work though.


Thanks a lot for your help

Nestor Montaño

unread,
Jun 21, 2013, 6:40:42 PM6/21/13
to shiny-...@googlegroups.com
It works for me!

Thanks

Yoni Sidi

unread,
Mar 28, 2016, 3:57:46 PM3/28/16
to Shiny - Web Framework for R
Hi 

I tried this now and it didnt work. Has the server settings changed since the this post? how to i write to disk on the server during the running of the application?

thanks

yoni

Joe Cheng

unread,
Mar 29, 2016, 10:04:02 AM3/29/16
to Yoni Sidi, Shiny - Web Framework for R
No, nothing should've changed--what error are you seeing?

Hána František

unread,
Mar 29, 2017, 4:17:05 AM3/29/17
to Shiny - Web Framework for R, yon...@gmail.com
Hi,
I have same problem with Docker (Rocker/shiny). For beter reproduction of this problem I create small app https://gist.github.com/sinacek/1e298396de11ea5277d94c99460be0c9 and tried run it in docker image https://hub.docker.com/r/rocker/shiny/ .
 
Thanks for help
Frantisek

Dne úterý 29. března 2016 16:04:02 UTC+2 Joe Cheng [RStudio] napsal(a):
Message has been deleted
Message has been deleted

Vivek Jayabalan

unread,
Jul 30, 2017, 5:37:18 AM7/30/17
to Shiny - Web Framework for R
Oh this brilliantly worked for me. However, I am a linux scrub. Wondering if you can modify this "sudo chown shiny:shiny /var/shiny-server/www/shiny_test/work" so that I can also edit the file?
Context: I update the file manually from an SQL Query Weekly, and I need responses from Shiny over the week

Tom Bowling

unread,
Oct 8, 2018, 7:39:57 AM10/8/18
to Shiny - Web Framework for R
I'm running in to this issue trying to save files to a folder called temp within my shiny app. I'm really new to using linux, so I could be missing something really obvious, but when I try

sudo chown shiny:shiny /srv/shiny-server/apps/SensoryApp/temp
I get
chown: invalid user: ‘shiny:shiny’

Is there an easy way to work out what i need to change to get this to work?

Tom Bowling

unread,
Oct 8, 2018, 11:30:24 AM10/8/18
to Shiny - Web Framework for R
As an update, I was running the shiny-server within a docker container, I had to create the shiny user on the linux VM - then change the permissions as per the "sudo chown" - then needed to get the container to mirror these permissions
Reply all
Reply to author
Forward
0 new messages