Reputation: 616
I am spinning up an instance of rstudio server and I need the working directory of R to be a specific directory. I would also like the file pane in the bottom right corner to be pointing to the same directory. Is there a way to do this? Currently it runs from the home directory of whichever user is running the program. I have tried the --server-working-dir
flag, and it does not seem to work. Here is the command I am using:
/usr/lib/rstudio-server/bin/rserver \
--server-daemonize=0 \
--server-user=user \
--server-working-dir=/some/path \
--auth-none=1 \
--auth-minimum-user-id=0
Any help would be useful here.
[edit] Just wanted to clarify that I would like the server to start in this directory. I am building a container that will be deployed multiple times, and I don't want the users to have to set their directories every time it is deployed.
Upvotes: 3
Views: 2265
Reputation: 46
If you want to modify the file pane in the right, you should edit /etc/rstudio/rsession.conf
.
And add two lines in below:
session-default-working-dir=/some/path
session-default-new-project-dir=/some/path
Upvotes: 3
Reputation: 2493
You should avoid overwriting the users home directory. Amongs the [.Rprofile] files you should only edit the Rprofile.site as a last resort since it acts globally.
Suggested solution:
R read the "initialization file" at start, in the following order:
In your case if you are planning to login to R-Studio server you will end up in the users home directory, so I would suggest you to just edit the [.Rprofile] in the home directory. In case the [.Rprofile] is missing you need to create it.
Add this line in your .Rprofile [in your home directory]:
setwd ('/your/path/')
Logout/login to your R-studio server session and you will notice that the "file pane to the right location" has changed accordingly to what you specified in your .Rprofile.
Upvotes: 0
Reputation: 9705
You can do this by edditing the (global) R profile startup script. Here's a step by step guide:
1) Run Rscript -e "R.home()"
-- this will tell you the location of your R directory home. In my case (Mac) it is /Library/Frameworks/R.framework/Resources
2) Go to /Library/Frameworks/R.framework/Resources/etc
-- e.g., $R_HOME/etc
3) sudo touch Rprofile.site
if it doesn't exist, then sudo nano Rprofile.site
4) Add the following lines and save:
cat("hi\n")
setwd("/some/path/")
Upvotes: 2