| osrm_install | R Documentation |
Downloads and installs pre-compiled binaries for the OSRM backend from the
official GitHub releases. The function automatically detects the user's
operating system and architecture to download the appropriate files. Only the
latest v5 release (v5.27.1), v6.0.0, v26.4.0 and v26.4.1 were manually
tested and are known to work well; other releases available on GitHub can be
installed but are not guranteed to function correctly.
osrm_install(
version = "latest",
dest_dir = NULL,
force = FALSE,
path_action = c("session", "project", "none"),
quiet = FALSE
)
version |
A string specifying the OSRM version tag to install.
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 |
The function performs the following steps:
Queries the GitHub API to find the specified release of
Project-OSRM/osrm-backend.
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.
macOS users should note that upstream OSRM v6.x (and newer) binaries are
built for macOS 15.0 (Sequoia, Darwin 24.0.0) or newer. osrm_install()
automatically blocks v6+ installs on older macOS releases and, when
version = "latest", selects the most recent v5 build instead while warning
about the requirement. Warnings include both the marketing version and Darwin
kernel so you'll see messages like macOS 13 Ventura [Darwin 22.6.0].
When installing OSRM v6.x or newer for Windows, the upstream release omits
the Intel Threading Building Blocks (TBB) runtime and a compatible bz2 DLL.
To keep the executables runnable out of the box, osrm_install() fetches TBB
from oneTBB
v2022.3.0 and the BZip2 runtime from
bzip2-windows
v1.0.8.0, verifying their SHA-256 checksums before extraction. Without these
extra libraries, the OSRM v6+ binaries shipped for Windows cannot start.
On macOS, OSRM v6.x and newer binaries also miss the bundled TBB runtime.
The installer reuses the libraries from release v5.27.1 to keep the
binaries functional and patches their libbz2 linkage using
install_name_tool so that they load the system-provided BZip2 runtime.
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.