| osrm_install | R Documentation |
Downloads and installs pre-compiled binaries for the OSRM backend. By
default, osrm_install() uses the e-kotov/osrm-binaries release repository,
which publishes immutable backend command-line archives primarily for this R
package. The upstream Project-OSRM/osrm-backend release repository can still
be used with osrm_binaries_provider = "official".
The function automatically detects the user's operating system and architecture to download the appropriate files. Validated versions are maintained by the package's live integration tests; see the OSRM live tests workflow and per-OS badges on GitHub Actions for the current validated versions. Other releases available on GitHub can be installed but are not guaranteed to function correctly.
osrm_install(
version = "latest",
osrm_binaries_provider = c("default", "official"),
dest_dir = NULL,
force = FALSE,
path_action = c("session", "project", "none"),
quiet = FALSE,
check_tested = TRUE,
download_url = NULL,
file_path = NULL
)
version |
A string specifying the OSRM version tag to install.
Defaults to |
osrm_binaries_provider |
A string specifying the provider to download binaries from.
Defaults to |
dest_dir |
A string specifying the directory where OSRM binaries should be
installed. If |
force |
A logical value. If |
path_action |
A string specifying how to handle the system
|
quiet |
A logical value. If |
check_tested |
A logical value. If |
download_url |
Advanced usage only. A direct URL to a |
file_path |
Advanced usage only. A local file path to a |
The function performs the following steps:
Queries the GitHub API to find the specified release of
e-kotov/osrm-binaries.
Identifies the correct binary (.tar.gz archive) for the user's OS
(Linux, macOS, or Windows) and architecture (x64, arm64).
Downloads the archive to a temporary location.
Extracts the archive and locates the OSRM executables (e.g.,
osrm-routed, osrm-extract).
Copies these executables to a local directory (defaults to
file.path(tools::R_user_dir("osrm.backend", which = "cache"), <version>)).
Downloads the matching Lua profiles from the release tarball and installs them alongside the binaries.
Optionally modifies the PATH environment variable for the current
session or project.
The osrm_binaries_provider argument allows choosing between two release sources:
"default" (e-kotov/osrm-binaries): This provider is highly recommended and is the
primary supported path for this R package. It offers standalone, immutable OSRM backend archives
with predictable asset names, bundled runtime libraries where practical, SHA-256 verification,
and no Node.js wrapper artifacts. It also provides native linux-arm64 and darwin-arm64
archives.
"official" (Project-OSRM/osrm-backend): The upstream releases provided by the core
OSRM team. These releases are intended primarily for upstream OSRM's Node.js distribution and are
packaged as node_osrm archives. Their platform coverage and bundled runtime libraries may differ
across OSRM versions, and recent upstream binaries may depend on runtime libraries from newer build
environments. osrm_install() keeps compatibility code for this provider, but it is a secondary
path rather than the package's main installation source.
Power users (including package authors running cross-platform tests) can
override the auto-detected platform by setting the R options
osrm.backend.override_os and osrm.backend.override_arch (e.g.,
options(osrm.backend.override_os = "linux", osrm.backend.override_arch = "arm64"))
before calling osrm_install(). Overrides allow requesting binaries for any
OS and CPU combination that exists on the GitHub releases.
The path to the installation directory.
if (identical(Sys.getenv("OSRM_EXAMPLES"), "true")) {
old <- setwd(tempdir())
on.exit(setwd(old), add = TRUE)
# Install the default stable version and set PATH for this session
install_dir <- osrm_install(path_action = "session", quiet = TRUE)
# Install for a project non-interactively (e.g., in a script)
osrm_install(path_action = "project", quiet = TRUE, force = TRUE)
# Clean up the project's .Rprofile and uninstall binaries
osrm_clear_path(quiet = TRUE)
osrm_uninstall(
dest_dir = install_dir,
clear_path = TRUE,
force = TRUE,
quiet = TRUE
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.