RStudio Pro permission issue with RStudio Connect markdown

I currently have a set up where I have an RMarkdown running and writing files to a persistant storage location that both Connect and RStudio Pro can see (location is a separate server that is mounted to the two connect and pro servers).

The issue I am running into is RStudio Pro cannot see the file that was written and I think it has to do with the permissions the run-as user 'rstudio-connect' uses when creating the files.

Below is the error:
file not found: /RStudioPro/Aftermarket_AUS/morrisk/MRODash/DataPrep//DataPrep_ShipmentsYear.csv

Reasons I think it is a permission issue:

  1. The same path is used in shiny applications where either the RStudio Pro or I (on windows side) create the files and both RStudio Pro and RStudio Connect can read them so I know it's not a path issue.

  2. Had an earlier issue when running the rmarkdown report in Server Pro, it read the files and published the files but when I published it to Connect, it was throwing a permissions error. I solved this by deleting the original files that were written when in Server Pro and that fixed it. Seemed Connect run-as could not overwrite files written by Pro run-as.

Yes, this does sound like a permissions / ownership issue.

In the Linux terminal you should be able to view the ownership of the file using ls -la, and change the ownership using chown. You can use these tools to confirm that it is in fact a file permissions issue.

One possible workaround for this is to create a different service account and change the run-as user in Connect to this service account.

image

You may also want to consider writing the data into a shared database location, rather than directly to file.

1 Like

Was able to fix it by changing the permissions on the file directly. I feel like rstudio-connect should be able to write with enough lax permissions that rstudio pro would be able to read it. Might be something to look into in the future (since for me, contacting our IT group to change the permissions for any file written is quite annoying).

Just a quick note, you get to set the permissions when you create the file :smile: So if creating lax permissions is what you want, you should be able to do that! It depends on how you're creating the file, but you can also use the fs package (or others, probably) to edit the permissions (e.g. file_chown or file_chmod) as the rstudio-connect user / owner after you create the file, if you want.

Gotta love programming languages!! :smiley:

Aside from lax permissions, the right / secure solution is as @andrie suggested - through managing user / group memberships. If everyone is a member of the same UNIX groups, you wouldn't run into this issue.