Skip to content

Commit b1e9a27

Browse files
committed
Detect path of rsession in default rstudio install automatically
For some reason the rstudio deb doesn't put executables in the normal locations
1 parent d65e838 commit b1e9a27

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

jupyter_rsession_proxy/__init__.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import tempfile
33
import subprocess
44
import getpass
5+
import shutil
56
from textwrap import dedent
67

78
def setup_shiny():
@@ -56,16 +57,25 @@ def _get_rsession_env(port):
5657
'RSTUDIO_DEFAULT_R_VERSION': version,
5758
}
5859

59-
return {
60-
'command': [
61-
'rsession',
60+
def _get_rsession_cmd(port):
61+
if shutil.which('rsession'):
62+
executable = 'rsession'
63+
else:
64+
# Default path for rsession if installed with the deb package
65+
executable = '/usr/lib/rstudio-server/bin/rsession'
66+
67+
return [
68+
executable,
6269
'--standalone=1',
6370
'--program-mode=server',
6471
'--log-stderr=1',
6572
'--session-timeout-minutes=0',
6673
'--user-identity=' + getpass.getuser(),
67-
'--www-port={port}'
68-
],
74+
'--www-port=' + str(port)
75+
]
76+
77+
return {
78+
'command': _get_rsession_cmd,
6979
'environment': _get_rsession_env,
7080
'title': 'RStudio',
7181
'icon': os.path.join(os.path.dirname(os.path.abspath(__file__)), 'icons', 'rstudio.svg')

0 commit comments

Comments
 (0)