How to upgrade 'cmake' on RSconnect?

Hello,

I have a Shiny app using the 'nloptr' package. The installation of this package requires CMake>=3.2, and then I get this error when deploying:

CMake 3.2 or higher is required. You are running version 2.8.12.2

Please take a look into Installing package nloptr.

The Downgrade option you can yourself run on your RStudio IDE or wherever you are pushing the shiny app from. The OS specific actions you need to run on your Connect environments (or have it run by your admins).

Thanks @michaelmayer.

We have Cmake>=3.2 but it is not in the path. So we can set the path like this:

HPC_cmake

Therefore I ran this code prior to deploying:


preDeploy <- function(path) {
  Sys.setenv(
    PATH = paste0("/hpc/apps/current/cmake/v3.6.0.app/bin/:", Sys.getenv("PATH"))
  )
}
options(rsconnect.pre.deploy = preDeploy)

But it had no effect.

I see: this code is executed on my laptop before deploying, not on the server.

1 Like

Another thing you could get away with is to install the OS package nlopt for your linux distro.

The package is named NLopt-devel on RHEL/CentOS (via the EPEL repository) and libnlopt-cxx-dev / libnlopt-devon Debian/ubuntu distros.

Or you really don't need nloptr 2.0+ and your code runs as well with nloptr 1.x. You then simply can install nloptr1.x locally to try it out with your app and rsconnect will then pick up this new version and not bother about cmake at all. (remotes_install("nloptr","1.2.2.3")would be your friend in this case).

It works!!! The .Rprofile file is read on the server. So I included this code in this file:

Sys.setenv(
  PATH = paste0("/hpc/apps/current/cmake/v3.6.0.app/bin/:", Sys.getenv("PATH"))
)

More precisely my .Rprofile file is:

LOCAL <- Sys.info()[["sysname"]] == "Windows"
if(LOCAL) { # renv stuff
  options(renv.settings.snapshot.type = "explicit")
  canReachCRAN <- pingr::is_up("cran.rstudio.com")
  if(canReachCRAN) {
    source("renv/activate.R")
  }
} else { # set path on RStudio connect
  Sys.setenv(
    PATH = paste0("/hpc/apps/current/cmake/v3.6.0.app/bin:", Sys.getenv("PATH"))
  )
}
1 Like