Install Posit Connect on Ubuntu

Overview
We want to test out the installation and management of Posit Connect (previously RStudio Connect).
Prerequisites
- A machine running Ubuntu
- I used a Windows machine with VMWare workstation 16 player and a clean install of Ubuntu 20.04 from ISO
- RStudio server installation (basically because this installation process includes the installation of r-base and I was hoping to test a single server with dual installation of RStudio server and Posit Connect)
- I followed the steps on this documentation page Download RStudio server
Infrastructure attempted
- Windows with a WSL
- I got issues when Posit Connect used
systemctl
withSystem has not been booted with systemd as init system (PID 1). Can't operate.
I’m thinking that my release of WSL didn’t support Systemd so I moved on to other options
- I got issues when Posit Connect used
- Virtual machine running Ubuntu
- I got this to work and the remaining blog post starts with this as a basis
- ChromeOS with Debian
- I actually tried this first and got issues with the service failing to start
- After trying the install on the virtual machine running Ubuntu and getting the same issue (which I resolved with a configuration change), I tried the configuration fix on ChromeOS debian and it worked
Installation
Following on this Posit documentation page Manually install Posit Connect. In my case, the Ubuntu installation I had was 20.04. (This same installation worked for Debian on ChromeOS)
sudo apt-get install gdebi-core
curl -O https://cdn.rstudio.com/connect/2022.12/rstudio-connect_2022.12.0~ubuntu20_amd64.deb
sudo gdebi rstudio-connect_2022.12.0~ubuntu20_amd64.deb
Initially this failed to start the service
After running the installation, test that the service is running.
sudo systemctl status rstudio-connect
For me, unfortunately, the service failed to start.
● rstudio-connect.service - Posit Connect
Loaded: loaded (/lib/systemd/system/rstudio-connect.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2023-01-04 01:15:02 PST; 116ms ago
Process: 20215 ExecStart=/opt/rstudio-connect/bin/connect --config /etc/rstudio-connect/rstudio-connect.gcfg (code=exited, status=1/FAILURE)
Main PID: 20215 (code=exited, status=1/FAILURE)
Jan 04 01:15:02 ubuntu systemd[1]: rstudio-connect.service: Scheduled restart job, restart counter is at 5.
Jan 04 01:15:02 ubuntu systemd[1]: Stopped Posit Connect.
Jan 04 01:15:02 ubuntu systemd[1]: rstudio-connect.service: Start request repeated too quickly.
Jan 04 01:15:02 ubuntu systemd[1]: rstudio-connect.service: Failed with result 'exit-code'.
Jan 04 01:15:02 ubuntu systemd[1]: Failed to start Posit Connect.
After checking the the log:
sudo cat /var/log/rstudio/rstudio-connect/rstudio-connect.log
I found the last log line showing that the reason the service cannot start is the Posit Connect cannot find the installation of R.
time="2023-01-04T09:15:02.118Z" level=fatal msg="Error: Unable to initialize local environment: Unable to use R on this system: Could not locate an R installation"
I’m not sure what default location for R that Posit Connect searches for. Let’s find out where R is installed on our system:
which R
Looks like it is installed in /usr/bin
.
/usr/bin/R
Change the configuration for the R install location
sudo vim /etc/rstudio-connect/rstudio-connect.gcfg
Initially I tried a configuration of /usr/bin/
but found that Posit Connect was by default adding bin
to the path and looking in /usr/bin/bin/
. This was the configuration that worked for me:
[Server]
RVersion = "/usr/"
Service working
Restart the service and check the status:
sudo systemctl restart rstudio-connect
sudo systemctl status rstudio-connect
● rstudio-connect.service - Posit Connect
Loaded: loaded (/lib/systemd/system/rstudio-connect.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-01-04 01:18:51 PST; 11s ago
Main PID: 20580 (connect)
Tasks: 22 (limit: 9408)
Memory: 26.1M
CGroup: /system.slice/rstudio-connect.service
├─20580 /opt/rstudio-connect/bin/connect --config /etc/rstudio-connect/rstudio-connect.gcfg
├─20622 /opt/rstudio-connect/ext/rserver-monitor --monitor-data-path /var/lib/rstudio-connect/metrics --monitor-interval-seconds 60 --monitor-domain-socket /tmp/connect-server/rserver-monitor.socke>
├─20628 /bin/sh -c '/usr/bin/rrdtool' '-'
└─20632 /usr/bin/rrdtool -
Jan 04 01:18:51 ubuntu systemd[1]: Started Posit Connect.
Jan 04 01:18:52 ubuntu rstudio-connect[20580]: time="2023-01-04T09:18:52.476Z" level=info msg="Loaded server migration from '/etc/rstudio-connect/rstudio-connect-migration.gcfg'"
Jan 04 01:18:52 ubuntu rstudio-connect[20580]: time="2023-01-04T09:18:52.480Z" level=info msg="The migration file does not affect the configuration"
Jan 04 01:18:52 ubuntu rstudio-connect[20580]: time="2023-01-04T09:18:52.480Z" level=info msg="Found 0 environment variables starting with 'CONNECT_' that may affect configuration.\n"
Jan 04 01:18:52 ubuntu rstudio-connect[20580]: time="2023-01-04T09:18:52.482Z" level=info msg="Using file /var/log/rstudio/rstudio-connect/rstudio-connect.log to store Server Logs."
Success, we have a installation of Posit Connect up and running.
Note: it is a 45 day free trial license.