Data (CSV) file is not read after publishing to Rstudio - permission denied

rstudioconnect

#1

Hello,
In my R script I have the following full path for reading the CSV file:

retailPrices <- unique(read.csv("/home/sagi/ricardo_data/retail_prices_UK_liquor.csv", sep=';',header=TRUE))

Im publishing the app to the server in which the directory /home/sagi/ricardo_data has a user and group rstudio-connect which is the user and group defined as default for the Rstudio server. To be FULLY covered the permissions to the directory and the file itself is 777 :

**-rwxrwxrwx. 1 rstudio-connect rstudio-connect 97700 May 5 00:07 retail_prices_UK_liquor.csv_**_
and still Im getting the following error code in the server:

2018/06/22 13:51:59.195682000 Warning in file(file, "rt") :
2018/06/22 13:51:59.195697879 cannot open file '/home/sagi/ricardo_data/retail_prices_UK_liquor.csv': Permission denied
2018/06/22 13:51:59.206808982 Error in value[3L] : cannot open the connection


#2

From within the R script, could you test the permissions of the other directories in the path? I expect that one of the directories does not permit the rstudio-connect user to traverse through.

Some organizations restrict permissions on user home directories. I would not be surprised to see that /home/sagi is not readable by the rstudio-connect user/group.

You can try using the R function "file.info" against each path to confirm access and inspect the permissions from the perspective of the rstudio-connect user running R. That would require deploying a (temporary) modification to your R script.

You should not need full "rwx" permissions on each component of the path. The following should be sufficient (this is not your only option):

permission user group           path
drwxr-xr-x root root            /home
drwxr-xr-x sagi sagi            /home/sagi
drwxr-x--- sagi rstudio-connect /home/sagi/ricardo_data 
-rwxr-x--- sagi rstudio-connect /home/sagi/ricardo_data/retail_prices_UK_liquor.csv 

This should allow read access by the rstudio-connect user (a member of the rstudio-connect group) to the CSV file. I've suggested group permissions in case you rely on the RunAs functionality of RStudio Connect and execute content with additional users.


#3

Thanks for the quick reply aron.

I have performed the following:

  1. Create a directory named ricardo under /var/lib/rstudio-connect
  2. The user/group of ricardo are rstudio-connect/rstudio-connect.
    drwxr-xr-x. 2 rstudio-connect rstudio-connect 4096 Jun 22 15:52 ricardo
  3. And just to be on the safe side for now provided the file retail_prices_UK_liquor.csv with the following permissions and user/group
    -rwxrwxrwx. 1 rstudio-connect rstudio-connect 97700 May 5 00:07 retail_prices_UK_liquor.csv

And still I get the same error....
Warning in file(file, "rt") :
2018/06/22 15:55:55.497040080 cannot open file '/var/lib/rstudio-connect/ricardo/retail_prices_UK_liquor.csv': Permission denied

Any other idea..?


#4

The directory underneath /var/lib/rstudio-connect is not readable because of how Connect performs its process sandboxing.

This is described here:
http://docs.rstudio.com/connect/admin/process-management.html#process-management-sandboxing

Try to find an alternate location for shared data.


#5

Super !
It works - thank you.