Open gaborcsardi opened 10 months ago
Random thought to use otool on mac? Could compare R version seen here with current R version!
r_version_last_compiled_on <- function(package, dir) {
# find `.so` file
dir <- file.path(dir, "src", paste0(package, ".so"))
# get libraries used
result <- processx::run(
"otool",
args = c("-L", dir)
)
if (result$status != 0L) {
# Don't know, process failed, say no.
return(FALSE)
}
if (length(result$stdout) == 0L) {
return(FALSE)
}
# here is what this looks like
cat("The stdout:\n")
cat(result$stdout)
cat("\n")
lines <- strsplit(result$stdout, "\n")[[1L]]
line <- lines[grepl("libR.dylib", lines, fixed = TRUE)]
if (length(line) != 1L) {
return(FALSE)
}
match <- stringr::str_match(
line,
"current version ([0|[1-9]\\d*]\\.[0|[1-9]\\d*]\\.0|[1-9]\\d*])"
)
if (nrow(match) != 1L || ncol(match) != 2L) {
return(FALSE)
}
match[[1L, 2L]]
}
package <- "rlang"
dir <- getwd()
r_version_last_compiled_on(package, dir)
The stdout:
/Users/davis/files/r/packages/rlang/src/rlang.so:
rlang.so (compatibility version 0.0.0, current version 0.0.0)
/Library/Frameworks/R.framework/Versions/4.5/Resources/lib/libR.dylib (compatibility version 4.5.0, current version 4.5.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2202.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.61.1)
[1] "4.5.0"
So that
pkgload::load_all()
recompiles in this case.