Debian Codegraph @

R/virtualization.R

raw
1
2 the$virtualization_type <- NULL
3
4 renv_virtualization_init <- function() {
5
6 type <- tryCatch(
7 renv_virtualization_type_impl(),
8 error = function(e) "unknown"
9 )
10
11 the$virtualization_type <- type
12
13 }
14
15 renv_virtualization_type <- function() {
16 the$virtualization_type
17 }
18
19 renv_virtualization_type_impl <- function() {
20
21 # only done on linux for now
22 if (!renv_platform_linux())
23 return("native")
24
25 # check for cgroup
26 if (file.exists("/proc/1/cgroup")) {
27 contents <- readLines("/proc/1/cgroup")
28 if (any(grepl("/docker/", contents)))
29 return("docker")
30 }
31
32 # assume native otherwise
33 "native"
34
35 }