2
2
local({
3
3
4
4
# the requested version of renv
5
- version <- " 1.0.3 "
5
+ version <- " 1.0.5 "
6
6
attr(version , " sha" ) <- NULL
7
7
8
8
# the project directory
@@ -31,6 +31,14 @@ local({
31
31
if (! is.null(override ))
32
32
return (override )
33
33
34
+ # if we're being run in a context where R_LIBS is already set,
35
+ # don't load -- presumably we're being run as a sub-process and
36
+ # the parent process has already set up library paths for us
37
+ rcmd <- Sys.getenv(" R_CMD" , unset = NA )
38
+ rlibs <- Sys.getenv(" R_LIBS" , unset = NA )
39
+ if (! is.na(rlibs ) && ! is.na(rcmd ))
40
+ return (FALSE )
41
+
34
42
# next, check environment variables
35
43
# TODO: prefer using the configuration one in the future
36
44
envvars <- c(
@@ -50,9 +58,22 @@ local({
50
58
51
59
})
52
60
53
- if (! enabled )
61
+ # bail if we're not enabled
62
+ if (! enabled ) {
63
+
64
+ # if we're not enabled, we might still need to manually load
65
+ # the user profile here
66
+ profile <- Sys.getenv(" R_PROFILE_USER" , unset = " ~/.Rprofile" )
67
+ if (file.exists(profile )) {
68
+ cfg <- Sys.getenv(" RENV_CONFIG_USER_PROFILE" , unset = " TRUE" )
69
+ if (tolower(cfg ) %in% c(" true" , " t" , " 1" ))
70
+ sys.source(profile , envir = globalenv())
71
+ }
72
+
54
73
return (FALSE )
55
74
75
+ }
76
+
56
77
# avoid recursion
57
78
if (identical(getOption(" renv.autoloader.running" ), TRUE )) {
58
79
warning(" ignoring recursive attempt to run renv autoloader" )
@@ -1041,7 +1062,7 @@ local({
1041
1062
# if jsonlite is loaded, use that instead
1042
1063
if (" jsonlite" %in% loadedNamespaces()) {
1043
1064
1044
- json <- catch (renv_json_read_jsonlite(file , text ))
1065
+ json <- tryCatch (renv_json_read_jsonlite(file , text ), error = identity )
1045
1066
if (! inherits(json , " error" ))
1046
1067
return (json )
1047
1068
@@ -1050,7 +1071,7 @@ local({
1050
1071
}
1051
1072
1052
1073
# otherwise, fall back to the default JSON reader
1053
- json <- catch (renv_json_read_default(file , text ))
1074
+ json <- tryCatch (renv_json_read_default(file , text ), error = identity )
1054
1075
if (! inherits(json , " error" ))
1055
1076
return (json )
1056
1077
@@ -1063,14 +1084,14 @@ local({
1063
1084
}
1064
1085
1065
1086
renv_json_read_jsonlite <- function (file = NULL , text = NULL ) {
1066
- text <- paste(text %|| % read (file ), collapse = " \n " )
1087
+ text <- paste(text %|| % readLines (file , warn = FALSE ), collapse = " \n " )
1067
1088
jsonlite :: fromJSON(txt = text , simplifyVector = FALSE )
1068
1089
}
1069
1090
1070
1091
renv_json_read_default <- function (file = NULL , text = NULL ) {
1071
1092
1072
1093
# find strings in the JSON
1073
- text <- paste(text %|| % read (file ), collapse = " \n " )
1094
+ text <- paste(text %|| % readLines (file , warn = FALSE ), collapse = " \n " )
1074
1095
pattern <- ' ["](?:(?:\\\\ .)|(?:[^"\\\\ ]))*?["]'
1075
1096
locs <- gregexpr(pattern , text , perl = TRUE )[[1 ]]
1076
1097
@@ -1118,14 +1139,14 @@ local({
1118
1139
map <- as.list(map )
1119
1140
1120
1141
# remap strings in object
1121
- remapped <- renv_json_remap (json , map )
1142
+ remapped <- renv_json_read_remap (json , map )
1122
1143
1123
1144
# evaluate
1124
1145
eval(remapped , envir = baseenv())
1125
1146
1126
1147
}
1127
1148
1128
- renv_json_remap <- function (json , map ) {
1149
+ renv_json_read_remap <- function (json , map ) {
1129
1150
1130
1151
# fix names
1131
1152
if (! is.null(names(json ))) {
@@ -1152,7 +1173,7 @@ local({
1152
1173
# recurse
1153
1174
if (is.recursive(json )) {
1154
1175
for (i in seq_along(json )) {
1155
- json [i ] <- list (renv_json_remap (json [[i ]], map ))
1176
+ json [i ] <- list (renv_json_read_remap (json [[i ]], map ))
1156
1177
}
1157
1178
}
1158
1179
0 commit comments