5

This is a follow up question to this (write.csv permisson shiny server - R).

I am using a shiny app to search and save some data. I was having problems getting folder permission. After reading this (https://groups.google.com/forum/#!topic/shiny-discuss/srWETT6uL-I) I managed to solve by running this is RStudio server shell:

sudo chown shiny:shiny /path_to_app/path_to_data

However, this doesn't seem to work for me anymore. When I click my save data button in my app, I get the familiar error:

cannot open compressed file 'mutec/mutec_data.rds', probable reason 'Permission denied

So I read this (https://askubuntu.com/questions/528411/how-do-you-view-file-permissions) to try and find out the folder permissions. I get this:

Mutec_data$ ls -l ./mutec total 4 -rw-r--r-- 1 pdowns pdowns 446 Apr 17 12:22 mutec_data.rds

I'm struggling to interpret this. Does it mean that user pdowns can read and write? Should there be a "shiny" user with read and write permission?

This is my saveData function:

outputDir <- "mutec"

saveData <- function(data) {
  # Write the file to the local system
  saveRDS(
    object = data,
    file = file.path(outputDir, "mutec_data.rds") 

  )
}

Update

When I check the permissions of a folder that does let me write, I get this:

PPL040_baseline$ ls -l ./ctest total 4 -rw-rw-r-- 1 shiny shiny 105 Apr 8 06:45 Consumed.csv

Which must mean I didn't get this bit correct:

sudo chown shiny:shiny ...

Cœur
  • 37,241
  • 25
  • 195
  • 267
Pete900
  • 2,016
  • 1
  • 21
  • 44

1 Answers1

7

Just to confirm for anyone who isn't familiar with Ubuntu, if this (https://groups.google.com/forum/#!topic/shiny-discuss/srWETT6uL-I) doesn't work for you then add -R after chown to change the folder permission. Thanks @warmoverflow

Pete900
  • 2,016
  • 1
  • 21
  • 44
  • 4
    Just to clarify the answer, in order to allow a Shiny app to write files to your local disk, i.e., you need to give the shiny user permissions over said folder with the following command: `sudo chown -R shiny:shiny /path_to_app/` – Bastián Olea Herrera May 06 '22 at 17:15