R/installed_libbi_version.r

Defines functions installed_libbi_version

Documented in installed_libbi_version

##' Get the LibBi version
##'
##' This tries to find the libbi executable to determine the installed version
##' of LibBi
##' @param ... any arguments for \code{\link{locate_libbi}} (esp.
##'   \code{path_to_libbi})
##' @return a character string with the installed version
##' @author Sebastian Funk
##' @importFrom processx run
##' @keywords internal
##' @export
installed_libbi_version <- function(...) {
  path_to_libbi <- locate_libbi(...)
  version <-
    tryCatch(processx::run(path_to_libbi, args = "--version")$stdout,
      error = function(e) NULL
    )
  if (is.null(version)) {
    return("pre-1.4.3")
  }
  version_string <- sub(
    "LibBi version[[:space:]]*([0-9\\.A-z]+).*$", "\\1", version
  )
  return(version_string)
}

Try the rbi package in your browser

Any scripts or data that you put into this service are public.

rbi documentation built on Aug. 15, 2023, 5:07 p.m.