Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra Simple (Autostarting) Local Version #32

Open
JZL opened this issue Mar 15, 2024 · 0 comments
Open

Extra Simple (Autostarting) Local Version #32

JZL opened this issue Mar 15, 2024 · 0 comments

Comments

@JZL
Copy link

JZL commented Mar 15, 2024

Hi,

Thanks for writing such a foundational useful package - I've pretty much only used R through this package!

This is only tangentially related to this package but could be useful for others.

One difficulty I found was some lab members never wanted to switch environments and preferred to have rstudio auto-start as normal, but with the (base/other) conda environment already setup. It was too easy to forget to activate the conda environment and get subtly different versions.

And I realized I could use the same rsession tricks but at the systemctl level (if the system uses systemd). So

Modify /lib/systemd/system/rstudio-server.service:

ExecStart=/usr/lib/rstudio-server/bin/rserver
-> ExecStart=/root/activateConda

(Run systemctl daemon-reload when first change)

and
Create /root/activateConda: (made executable)

#!/bin/bash
eval "$(/home/jlanglie/anaconda3/bin/conda shell.bash hook)"
source /home/jlanglie/anaconda3/etc/profile.d/conda.sh

conda activate base
/usr/lib/rstudio-server/bin/rserver \
  --rsession-which-r=$(which R)     \
  --rsession-ld-library-path=$CONDA_PREFIX/lib

The main disadvantage is unless you modify that file, you can't easily change the conda environment. But if you did modify the file then you only have to do sudo systemctl restart rstudio-server.service for it to reload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant