Cannot find compatible Local environment version of R when deploying to RStudio Connect

Getting a seemingly obvious error (that I can't figure out how to troubleshoot) when trying to deploy any content to RStudio Connect on Apache Ubuntu 20.04 server.

"Cannot find compatible environment: no compatible Local environment with R version 4.1.2"

We specified R 4.1.2 in the manifest.json file, and R 4.1.2 is on PATH of the server. Any help would be greatly appreciated!

Which versions of R do you have installed on the server and where are they located? Which R versions are recognized by Connect, i.e. which are shown at the bottom of the "Documentation" tab? Do you use any RVersion* settings in /etc/rstudio-connect/rstudio-connect.gcfg?

1 Like

I see R installed in 2 places:

/usr/lib/R -- version 3.6.3 (this is the version of R that RStudio Connect is using)
/opt/R -- version 4.1.2 (this is the version of R that I would like RStudio Connect to use instead)

Note that the version of R on the PATH is also 4.1.2.

The "Documentation" tab shows only version 3.6.3 recognized.

Is it an acceptable solution to update the version of R at /usr/lib/R to a newer version (e.g., 4.1.2)? If so, are there any best practices for executing that update safely?

I did try adding the following line to the /etc/rstudio-connect/rstudio-connect.gcfg file:

[Server]
RVersion = /opt/R/4.1.2

And I restarted the service via sudo systemctl restart rstudio-connect, but the issue still remains (can only find 3.6.3 on deployment from RStudio IDE, and the "Documentation" tab still only shows 3.6.3)

However, when I add RVersionScanning = false to that block, it breaks RStudio Connect altogether (I receive a 503 error in the browser)

Interesting, do you get any errors in the log file? Maybe some of the file permissions are to tight? You can check that with namei -l $(which R).

Here's what I get when I try checking the file permissions as you described:

root@inresgb-0002:/# namei -l $(which R)
f: /usr/local/bin/R
drwxr-xr-x root root /
drwxr-xr-x root root usr
drwxr-xr-x root root local
drwxr-xr-x root root bin
lrwxrwxrwx root root R -> /opt/R/4.1.2/bin/R
drwxr-xr-x root root   /
drwxr-xr-x root root   opt
drwxr-xr-x root root   R
drwxr-xr-x root root   4.1.2
drwxr-xr-x root root   bin
-rwxr-xr-x root root   R

Thanks, the permissions seem to be correct. Any error messages in the server log?

I really appreciate the continued help, Ralf!

Here's what I see for error messages in the server log -- this might be helpful:

2022/04/06 17:15:18 Could not detect R at /opt/R/4.1.2/bin/R: Could not run R as rstudio-connect; exit status 1; received output: '/opt/R/4.1.2/bin/R: line 1                  93: /usr/bin/sed: No such file or directory
ERROR: option '-e' requires a non-empty argument'
2022/04/06 17:15:18 Could not detect R at /opt/R/4.1.2/bin/R: Could not run R as rstudio-connect; exit status 1; received output: '/opt/R/4.1.2/bin/R: line 1                  93: /usr/bin/sed: No such file or directory
ERROR: option '-e' requires a non-empty argument'
2022/04/06 17:15:18 Detected R version 3.6.3 at /usr/lib/R/bin/R
2022/04/06 17:15:18 Warning: Using system-provided R (/usr/lib/R/bin/R, discovered via Server.RVersionScanning) is not recommended. Installing the desired R                   versions from source will help avoid unexpected version changes. Use Server.RVersion to enumerate the different R installations on this server. See https://d                  ocs.rstudio.com/connect/admin/getting-started/#installation.

I assume it is trying to use the R version I specified in the rstudio-connect.gcfg file, but is expecting some directory (usr/bin/sed) that doesn't exist?

I'm not sure if this helps either, but there are a lot more files in /usr/lib/R/bin (which is where RStudio Connect is getting R) than there are in /opt/R/4.1.2/bin/ (which is where I want RStudio Connect to get R from)

image

It is looking for the sed program in /usr/bin/sed. It is unusual that this file does not exist. Is sed installed? You can test that with which sed and dpkg -l sed. If it is not installed, you can use sudo apt-get install sed to install it.

Here's what I get from running those two commands:

root@inresgb-0002:/# which sed
/bin/sed

and

root@inresgb-0002:/# dpkg -l sed
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================================
ii  sed            4.7-1        amd64        GNU stream editor for filtering/transforming text

It looks like sed is installed at /bin/sed (but not at /usr/bin/sed, where RStudio Connect is looking for it), but perhaps it is also corrupt based upon some of the output from the second command above?

This is really interesting. The script that launches R expects /usr/bin/sed, which is determined when R is configured and built. How was your server provisioned? What R install are you using?

For reference, the ubuntu:20.04 Docker image has /bin as a symbolic link to /usr/bin, meaning /bin/sed and /usr/bin/sed are both valid paths, even though the sed package only installs into /bin/sed.

The symlinking of /bin and /usr/bin appears to be the case for new Ubuntu installs, but perhaps not upon upgrades. Why are /bin and /sbin now symlinks in Ubuntu 20.04? - Ask Ubuntu

For now, I would recommend creating a symlink from /usr/bin/sed to /bin/sed.

1 Like

One other breadcrumb: R determines the location of sed when it is configured and built; that system probably finds /usr/bin/sed first and uses that going forward.
https://github.com/wch/r-source/blob/7c286ab419c0be5fddfd50c71a3fd8b228751631/configure.ac#L679-L680

1 Like

Creating the symlink solved the issue! I can't thank you enough for the help @aron & @rstub ! This was clearly over my head :sweat_smile: and a good reminder to always check the logs first...

Thank you again so much.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.