Posit Connect Publishing - Cannot create dir '/opt/rstudio-connect/mnt/', reason 'Permission denied'

Follow

When publishing, you may see an error similar to the below:

[Connect] Failed to create directory: /opt/rstudio-connect/mnt/
[Connect] In addition: Warning message:
[Connect] In dir.create(path, recursive = TRUE) :
[Connect] cannot create dir '/opt/rstudio-connect/mnt/', reason 'Permission denied'
[Connect] Execution halted
[Connect] Build error: exit status 1

The error message above is slightly misleading! The sandboxing feature used by RStudio Connect involves bind mounts that map physical locations on disk onto different directory structures at runtime. Paths used by your code use these sandboxed locations.

More information on this can be found here:

https://docs.rstudio.com/connect/admin/process-management/#path-rewriting

 

Your default instinct may be to change permissions on the sandbox path! However, the resolution for this is to change the ownership of your Server.DataDir to ensure that it is owned by your Application.RunAs user. By default, rstudio-connect is your Application.RunAs user, and your default Server.DataDir location is /var/lib/rstudio-connect.

 

In the case above, you will need to ensure that your RunAs user has execute permissions on your Data Directory:

sudo chown -R rstudio-connect:rstudio-connect /var/lib/rstudio-connect

Alternatively, if you are using a different Application.RunAs user and a different Server.DataDir, you will need to run a command similar to the below:

sudo chown -R <Application.RunAs>:<Application.RunAs> <Server.DataDir>

Where Application.RunAs is your RunAs user and Server.DataDir is your alternate data directory.

 

 

Support Ticket

If you still have issues after completing the above, you can always lodge a support ticket, where our group of friendly, and incredibly knowledgeable staff can assist with any issues that you may be having. You can submit a ticket here:

https://support.rstudio.com/hc/en-us/requests/new

Comments