@@ -65,20 +65,15 @@
Loading
65 65
    " {.timestamp {total_time}}"))
66 66
}
67 67
68 -
warn_for_loaded_packages <- function(pkgs, lib) {
69 -
  if (length(maybe_bad <- intersect(pkgs, loadedNamespaces()))) {
70 -
    loaded_from <- vcapply(
71 -
      maybe_bad,
72 -
      function(x) dirname(getNamespaceInfo(x, "path"))
68 +
warn_for_loaded_packages <- function(pkgs, lib, loaded) {
69 +
  if (is.null(loaded)) return()
70 +
  bad <- intersect(pkgs, loaded)
71 +
  bad <- setdiff(bad, "pak")
72 +
  if (length(bad)) {
73 +
    cli::cli_alert_warning(
74 +
      "{.pkg {bad}} {?is/are} loaded in this session, \\
75 +
       you probably need to restart R after the installation.",
76 +
      wrap = TRUE
73 77
    )
74 -
    bad <- maybe_bad[normalizePath(loaded_from) == normalizePath(lib)]
75 -
    bad <- setdiff(bad, "pak")
76 -
    if (length(bad)) {
77 -
      cli::cli_alert_warning(
78 -
        "Package(s) {format_items(bad)} are already loaded, installing \\
79 -
         them may cause problems. Use {.code pkgload::unload()} to unload them.",
80 -
        wrap = TRUE
81 -
      )
82 -
    }
83 78
  }
84 79
}

@@ -219,7 +219,7 @@
Loading
219 219
    proposal = prop, start = start, lib = dirs$lib, root = dirs$root, pkg = pkg)
220 220
221 221
  sol <- prop$get_solution()$data
222 -
  print_install_details(sol, dirs$lib)
222 +
  print_install_details(sol, dirs$lib, NULL)
223 223
}
224 224
225 225
proj_install_do_plan <- function(optional) {

@@ -2,8 +2,10 @@
Loading
2 2
print_package_list <- function(x, new_version = NULL, old_version = NULL) {
3 3
  cli::cli_div(
4 4
    class = "pkglist",
5 -
    theme = list(div.pkglist = list("margin-left" = 2)))
6 -
5 +
    theme = list(
6 +
      div.pkglist = list("margin-left" = 2)
7 +
    )
8 +
  )
7 9
  if (!is.null(new_version) && !is.null(old_version)) {
8 10
    x <- paste0(x, " (", old_version, " ", cli::symbol$arrow_right, " ",
9 11
                new_version, ")")
@@ -19,7 +21,13 @@
Loading
19 21
  any(sol$lib_status == "update")
20 22
}
21 23
22 -
print_install_details <- function(sol, lib) {
24 +
print_install_details <- function(sol, lib, loaded) {
25 +
  cli::cli_div(
26 +
    theme = list(
27 +
      "div.alert-warning" = list("margin-top" = 1, "margin-bottom" = 1)
28 +
    )
29 +
  )
30 +
23 31
  direct <- sum(sol$direct)
24 32
  deps <- sum(! sol$direct)
25 33
@@ -43,8 +51,6 @@
Loading
43 51
    print_package_list(sol$ref[upd], sol$version[upd], sol$old_version[upd])
44 52
  }
45 53
46 -
  warn_for_loaded_packages(sol$package[newly | upd], lib)
47 -
48 54
  w_dl <- sol$cache_status == "miss" & !is.na(sol$cache_status)
49 55
  w_ch <- sol$cache_status == "hit" & !is.na(sol$cache_status)
50 56
  n_dl <- sum(w_dl, na.rm = TRUE)
@@ -80,6 +86,10 @@
Loading
80 86
    }
81 87
  }
82 88
89 +
  if (length(loaded) > 0) {
90 +
    warn_for_loaded_packages(sol$package[newly | upd], lib, loaded)
91 +
  }
92 +
83 93
  invisible(should_ask)
84 94
}
85 95

@@ -79,7 +79,8 @@
Loading
79 79
    function(...) {
80 80
      get("local_install_dev_deps_make_plan", asNamespace("pak"))(...)
81 81
    },
82 -
    list(root = root, lib = lib, upgrade = upgrade, start = start))
82 +
    list(root = root, lib = lib, upgrade = upgrade, start = start,
83 +
         loaded = loaded_packages(lib)))
83 84
84 85
  if (any && ask) get_confirmation("? Do you want to continue (Y/n) ")
85 86
@@ -96,7 +97,8 @@
Loading
96 97
97 98
## Almost the same as a "regular" install, but need to set dependencies
98 99
99 -
local_install_dev_deps_make_plan <- function(root, lib, upgrade, start) {
100 +
local_install_dev_deps_make_plan <- function(root, lib, upgrade, start,
101 +
                                             loaded) {
100 102
  prop <- pkgdepends::new_pkg_installation_proposal(
101 103
    paste0("deps::", root),
102 104
    config = list(library = lib, dependencies = TRUE)
@@ -107,7 +109,7 @@
Loading
107 109
  prop$stop_for_solution_error()
108 110
  pkg_data$tmp <- list(proposal = prop, start = start)
109 111
  sol <- prop$get_solution()$data
110 -
  print_install_details(sol, lib)
112 +
  print_install_details(sol, lib, loaded)
111 113
}
112 114
113 115
## This is the same as a regular install

@@ -191,7 +191,8 @@
Loading
191 191
192 192
  any <- remote(
193 193
    function(...) get("pkg_install_make_plan", asNamespace("pak"))(...),
194 -
    list(pkg = pkg, lib = lib, upgrade = upgrade, ask = ask, start = start))
194 +
    list(pkg = pkg, lib = lib, upgrade = upgrade, ask = ask,
195 +
         start = start, loaded = loaded_packages(lib)))
195 196
196 197
  if (any && ask) {
197 198
    get_confirmation("? Do you want to continue (Y/n) ")
@@ -204,7 +205,7 @@
Loading
204 205
  invisible(inst)
205 206
}
206 207
207 -
pkg_install_make_plan <- function(pkg, lib, upgrade, ask, start) {
208 +
pkg_install_make_plan <- function(pkg, lib, upgrade, ask, start, loaded) {
208 209
  prop <- pkgdepends::new_pkg_installation_proposal(
209 210
    pkg,
210 211
    config = list(library = lib)
@@ -216,7 +217,7 @@
Loading
216 217
  prop$stop_for_solution_error()
217 218
  pkg_data$tmp <- list(proposal = prop, start = start)
218 219
  sol <- prop$get_solution()$data
219 -
  print_install_details(sol, lib)
220 +
  print_install_details(sol, lib, loaded)
220 221
}
221 222
222 223
pkg_install_do_plan <- function(proposal, lib) {

@@ -245,3 +245,12 @@
Loading
245 245
    interactive()
246 246
  }
247 247
}
248 +
249 +
loaded_packages <- function(lib) {
250 +
  lib <- normalizePath(lib)
251 +
  pkgs <- setdiff(loadedNamespaces(), base_packages())
252 +
  libs <- vcapply(pkgs, function(x) dirname(getNamespaceInfo(x, "path")))
253 +
254 +
  bad <- normalizePath(libs) == lib
255 +
  pkgs[bad]
256 +
}
Files Coverage
R 34.67%
Project Totals (16 files) 34.67%
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 1%
9
        informational: true
10
    patch:
11
      default:
12
        target: auto
13
        threshold: 1%
14
        informational: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading