Posit/RStudio Connect with devtoolset enabled


 (While these instructions were developed for CentOS 6 and devtoolset-7, they will work for CentOS 7 and devtoolset-10, as well, if you are seeing the same error or would like to use a newer version of GCC.) 

When using Posit/RStudio Connect on CentOS/RHEL 6, a common issue is the GCC version available is not sufficient for C++ 2011 code.  This will return errors similar to the following for example, when installing the odbc package: 

cc1plus: error: unrecognized command line option "-std=c++11"

To work around this issue, you can install and enable the devtoolset. 

For example, on CentOS 6:

  1. yum install centos-release-scl
  2. yum install devtoolset-7
  3. Execute: gcc -v
  4. Enable devtoolset-7 with:  source scl_source enable devtoolset-7
  5. Review gcc version now with:  gcc -v

Once tested, you can implement this on Posit/RStudio Connect using a program supervisor.

For example:

1.  Create a directory to store your program supervisor script.  Note that this directory must be accessible by the sandbox.  Below is an ideal directory example:

mkdir -p /opt/scripts

2.  Script contents:

cat /opt/scripts/devtool-enable.sh


echo arguments: "$@" >&2
echo >&2

source scl_source enable devtoolset-7

exec "$@"

 3. Allow access to the file with:  chmod 755 /opt/scripts/devtool-enable.sh

4.  Add the following to /etc/rstudio-connect/rstudio-connect.gcfg

Supervisor = /opt/scripts/devtool-enable.sh

Afterwards, please restart the Posit/RStudio Connect service. 

When content is deployed, you should see the new GCC version in use to compile packages.  This will allow you to deploy content using R packages which require a C++ 11 compatible compiler.



This is an uncommon requirement but is sometimes necessary to make this available to R outside of Posit/RStudio Connect. In this situation, the changes you make will depend on the level of C++ compiler that you need but follows the following format.

Add or edit a file in each version of R that you have installed

# usually /opt/R/<R-Version>/lib/R/etc/Makevars.site

with the following content

CXX14 = g++ -std=c++1y