-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path000_install_dependencies.R
More file actions
31 lines (23 loc) · 960 Bytes
/
000_install_dependencies.R
File metadata and controls
31 lines (23 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env Rscript
# Restore the pinned project library from renv.lock.
is_macos <- identical(Sys.info()[["sysname"]], "Darwin")
options(repos = c(CRAN = "https://cloud.r-project.org"))
options(renv.consent = TRUE)
if (!file.exists("renv.lock")) {
stop("File not found: renv.lock\nThis project uses renv for reproducible dependencies.")
}
if (is_macos) {
binary_repo <- utils::contrib.url(getOption("repos"), type = "binary")
source_repo <- utils::contrib.url(getOption("repos"), type = "source")
has_cran_binaries <- !identical(binary_repo, source_repo) && grepl("/bin/", binary_repo)
options(pkgType = if (has_cran_binaries) "binary" else "source")
}
if (!requireNamespace("renv", quietly = TRUE)) {
message("Installing renv...")
install.packages("renv")
}
message("Restoring packages from renv.lock...")
renv::restore(prompt = FALSE)
source("dev/renv_status.R")
assert_renv_synchronized()
message("\nDone. Run: Rscript run_all.R")