yihui 我把 debug 的代码放在 sysfonts 里,重新安装 sysfonts 信息如下:
library(sysfonts)
library(showtext)
#> Loading required package: showtextdb
#> NULL
#> [[1]]
#> tryCatch(withCallingHandlers({
#> NULL
#> saveRDS(do.call(do.call, c(readRDS("/tmp/RtmpaeHHFY/callr-fun-b6843298d7"),
#> list(envir = .GlobalEnv)), envir = .GlobalEnv), file = "/tmp/RtmpaeHHFY/callr-res-b6858eeb722")
#> flush(stdout())
#> flush(stderr())
#> NULL
#> invisible()
#> }, error = function(e) {
#> {
#> callr_data <- as.environment("tools:callr")$`__callr_data__`
#> err <- callr_data$err
#> capture.output(assign(".Traceback", traceback(9), envir = baseenv()))
#> dump.frames("__callr_dump__")
#> assign(".Last.dump", .GlobalEnv$`__callr_dump__`, envir = callr_data)
#> rm("__callr_dump__", envir = .GlobalEnv)
#> e2 <- err$new_error(conditionMessage(e), call. = conditionCall(e))
#> class(e2) <- c("callr_remote_error", class(e2))
#> e2$error <- e
#> calls <- sys.calls()
#> dcframe <- which(vapply(calls, function(x) length(x) >=
#> 1 && identical(x[[1]], quote(do.call)), logical(1)))[1]
#> if (!is.na(dcframe))
#> e2$`_ignore` <- list(c(1, dcframe + 1L))
#> e2$`_pid` <- Sys.getpid()
#> e2$`_timestamp` <- Sys.time()
#> if (inherits(e, "rlib_error"))
#> e2$parent <- e$parent
#> e2 <- err$add_trace_back(e2)
#> saveRDS(list("error", e2), file = paste0("/tmp/RtmpaeHHFY/callr-res-b6858eeb722",
#> ".error"))
#> }
#> }, interrupt = function(e) {
#> {
#> callr_data <- as.environment("tools:callr")$`__callr_data__`
#> err <- callr_data$err
#> capture.output(assign(".Traceback", traceback(9), envir = baseenv()))
#> dump.frames("__callr_dump__")
#> assign(".Last.dump", .GlobalEnv$`__callr_dump__`, envir = callr_data)
#> rm("__callr_dump__", envir = .GlobalEnv)
#> e2 <- err$new_error(conditionMessage(e), call. = conditionCall(e))
#> class(e2) <- c("callr_remote_error", class(e2))
#> e2$error <- e
#> calls <- sys.calls()
#> dcframe <- which(vapply(calls, function(x) length(x) >=
#> 1 && identical(x[[1]], quote(do.call)), logical(1)))[1]
#> if (!is.na(dcframe))
#> e2$`_ignore` <- list(c(1, dcframe + 1L))
#> e2$`_pid` <- Sys.getpid()
#> e2$`_timestamp` <- Sys.time()
#> if (inherits(e, "rlib_error"))
#> e2$parent <- e$parent
#> e2 <- err$add_trace_back(e2)
#> saveRDS(list("error", e2), file = paste0("/tmp/RtmpaeHHFY/callr-res-b6858eeb722",
#> ".error"))
#> }
#> }, callr_message = function(e) {
#> try(signalCondition(e))
#> }), error = function(e) {
#> NULL
#> try(stop(e))
#> }, interrupt = function(e) {
#> NULL
#> e
#> })
#>
#> [[2]]
#> tryCatchList(expr, classes, parentenv, handlers)
#>
#> [[3]]
#> tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),
#> names[nh], parentenv, handlers[[nh]])
#>
#> [[4]]
#> doTryCatch(return(expr), name, parentenv, handler)
#>
#> [[5]]
#> tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#>
#> [[6]]
#> tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>
#> [[7]]
#> doTryCatch(return(expr), name, parentenv, handler)
#>
#> [[8]]
#> withCallingHandlers({
#> NULL
#> saveRDS(do.call(do.call, c(readRDS("/tmp/RtmpaeHHFY/callr-fun-b6843298d7"),
#> list(envir = .GlobalEnv)), envir = .GlobalEnv), file = "/tmp/RtmpaeHHFY/callr-res-b6858eeb722")
#> flush(stdout())
#> flush(stderr())
#> NULL
#> invisible()
#> }, error = function(e) {
#> {
#> callr_data <- as.environment("tools:callr")$`__callr_data__`
#> err <- callr_data$err
#> capture.output(assign(".Traceback", traceback(9), envir = baseenv()))
#> dump.frames("__callr_dump__")
#> assign(".Last.dump", .GlobalEnv$`__callr_dump__`, envir = callr_data)
#> rm("__callr_dump__", envir = .GlobalEnv)
#> e2 <- err$new_error(conditionMessage(e), call. = conditionCall(e))
#> class(e2) <- c("callr_remote_error", class(e2))
#> e2$error <- e
#> calls <- sys.calls()
#> dcframe <- which(vapply(calls, function(x) length(x) >=
#> 1 && identical(x[[1]], quote(do.call)), logical(1)))[1]
#> if (!is.na(dcframe))
#> e2$`_ignore` <- list(c(1, dcframe + 1L))
#> e2$`_pid` <- Sys.getpid()
#> e2$`_timestamp` <- Sys.time()
#> if (inherits(e, "rlib_error"))
#> e2$parent <- e$parent
#> e2 <- err$add_trace_back(e2)
#> saveRDS(list("error", e2), file = paste0("/tmp/RtmpaeHHFY/callr-res-b6858eeb722",
#> ".error"))
#> }
#> }, interrupt = function(e) {
#> {
#> callr_data <- as.environment("tools:callr")$`__callr_data__`
#> err <- callr_data$err
#> capture.output(assign(".Traceback", traceback(9), envir = baseenv()))
#> dump.frames("__callr_dump__")
#> assign(".Last.dump", .GlobalEnv$`__callr_dump__`, envir = callr_data)
#> rm("__callr_dump__", envir = .GlobalEnv)
#> e2 <- err$new_error(conditionMessage(e), call. = conditionCall(e))
#> class(e2) <- c("callr_remote_error", class(e2))
#> e2$error <- e
#> calls <- sys.calls()
#> dcframe <- which(vapply(calls, function(x) length(x) >=
#> 1 && identical(x[[1]], quote(do.call)), logical(1)))[1]
#> if (!is.na(dcframe))
#> e2$`_ignore` <- list(c(1, dcframe + 1L))
#> e2$`_pid` <- Sys.getpid()
#> e2$`_timestamp` <- Sys.time()
#> if (inherits(e, "rlib_error"))
#> e2$parent <- e$parent
#> e2 <- err$add_trace_back(e2)
#> saveRDS(list("error", e2), file = paste0("/tmp/RtmpaeHHFY/callr-res-b6858eeb722",
#> ".error"))
#> }
#> }, callr_message = function(e) {
#> try(signalCondition(e))
#> })
#>
#> [[9]]
#> saveRDS(do.call(do.call, c(readRDS("/tmp/RtmpaeHHFY/callr-fun-b6843298d7"),
#> list(envir = .GlobalEnv)), envir = .GlobalEnv), file = "/tmp/RtmpaeHHFY/callr-res-b6858eeb722")
#>
#> [[10]]
#> do.call(do.call, c(readRDS("/tmp/RtmpaeHHFY/callr-fun-b6843298d7"),
#> list(envir = .GlobalEnv)), envir = .GlobalEnv)
#>
#> [[11]]
#> (function (what, args, quote = FALSE, envir = parent.frame())
#> {
#> if (!is.list(args))
#> stop("second argument must be a list")
#> if (quote)
#> args <- lapply(args, enquote)
#> .Internal(do.call(what, args, envir))
#> })(function (input)
#> {
#> options(keep.source = TRUE, rlang_trace_top_env = globalenv(),
#> crayon.enabled = FALSE)
#> rmarkdown::render(input, quiet = TRUE, envir = globalenv())
#> }, list(input = "/tmp/RtmpaeHHFY/reprexb68a3066e3/reprex_reprex.R"),
#> envir = <environment>)
#>
#> [[12]]
#> (function (input)
#> {
#> options(keep.source = TRUE, rlang_trace_top_env = globalenv(),
#> crayon.enabled = FALSE)
#> rmarkdown::render(input, quiet = TRUE, envir = globalenv())
#> })(input = "/tmp/RtmpaeHHFY/reprexb68a3066e3/reprex_reprex.R")
#>
#> [[13]]
#> rmarkdown::render(input, quiet = TRUE, envir = globalenv())
#>
#> [[14]]
#> knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
#>
#> [[15]]
#> process_file(text, output)
#>
#> [[16]]
#> withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),
#> error = function(e) {
#> setwd(wd)
#> cat(res, sep = "\n", file = output %n% "")
#> message("Quitting from lines ", paste(current_lines(i),
#> collapse = "-"), " (", knit_concord$get("infile"),
#> ") ")
#> })
#>
#> [[17]]
#> process_group(group)
#>
#> [[18]]
#> process_group.block(group)
#>
#> [[19]]
#> call_block(x)
#>
#> [[20]]
#> block_exec(params)
#>
#> [[21]]
#> in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE,
#> keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message),
#> stop_on_error = if (options$error && options$include) 0L else 2L,
#> output_handler = knit_handlers(options$render, options)))
#>
#> [[22]]
#> evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning),
#> keep_message = !isFALSE(options$message), stop_on_error = if (options$error &&
#> options$include) 0L else 2L, output_handler = knit_handlers(options$render,
#> options))
#>
#> [[23]]
#> evaluate::evaluate(...)
#>
#> [[24]]
#> evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos,
#> debug = debug, last = i == length(out), use_try = stop_on_error !=
#> 2L, keep_warning = keep_warning, keep_message = keep_message,
#> output_handler = output_handler, include_timing = include_timing)
#>
#> [[25]]
#> timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr,
#> envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
#>
#> [[26]]
#> handle(ev <- withCallingHandlers(withVisible(eval(expr, envir,
#> enclos)), warning = wHandler, error = eHandler, message = mHandler))
#>
#> [[27]]
#> try(f, silent = TRUE)
#>
#> [[28]]
#> tryCatch(expr, error = function(e) {
#> call <- conditionCall(e)
#> if (!is.null(call)) {
#> if (identical(call[[1L]], quote(doTryCatch)))
#> call <- sys.call(-4L)
#> dcall <- deparse(call)[1L]
#> prefix <- paste("Error in", dcall, ": ")
#> LONG <- 75L
#> sm <- strsplit(conditionMessage(e), "\n")[[1L]]
#> w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")
#> if (is.na(w))
#> w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],
#> type = "b")
#> if (w > LONG)
#> prefix <- paste0(prefix, "\n ")
#> }
#> else prefix <- "Error : "
#> msg <- paste0(prefix, conditionMessage(e), "\n")
#> .Internal(seterrmessage(msg[1L]))
#> if (!silent && isTRUE(getOption("show.error.messages"))) {
#> cat(msg, file = outFile)
#> .Internal(printDeferredWarnings())
#> }
#> invisible(structure(msg, class = "try-error", condition = e))
#> })
#>
#> [[29]]
#> tryCatchList(expr, classes, parentenv, handlers)
#>
#> [[30]]
#> tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>
#> [[31]]
#> doTryCatch(return(expr), name, parentenv, handler)
#>
#> [[32]]
#> withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler,
#> error = eHandler, message = mHandler)
#>
#> [[33]]
#> withVisible(eval(expr, envir, enclos))
#>
#> [[34]]
#> eval(expr, envir, enclos)
#>
#> [[35]]
#> eval(expr, envir, enclos)
#>
#> [[36]]
#> library(showtext)
#>
#> [[37]]
#> tryCatch({
#> attr(package, "LibPath") <- which.lib.loc
#> ns <- loadNamespace(package, lib.loc)
#> env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)
#> }, error = function(e) {
#> P <- if (!is.null(cc <- conditionCall(e)))
#> paste(" in", deparse(cc)[1L])
#> else ""
#> msg <- gettextf("package or namespace load failed for %s%s:\n %s",
#> sQuote(package), P, conditionMessage(e))
#> if (logical.return)
#> message(paste("Error:", msg), domain = NA)
#> else stop(msg, call. = FALSE, domain = NA)
#> })
#>
#> [[38]]
#> tryCatchList(expr, classes, parentenv, handlers)
#>
#> [[39]]
#> tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>
#> [[40]]
#> doTryCatch(return(expr), name, parentenv, handler)
#>
#> [[41]]
#> loadNamespace(package, lib.loc)
#>
#> [[42]]
#> runHook(".onLoad", env, package.lib, package)
#>
#> [[43]]
#> tryCatch(fun(libname, pkgname), error = identity)
#>
#> [[44]]
#> tryCatchList(expr, classes, parentenv, handlers)
#>
#> [[45]]
#> tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>
#> [[46]]
#> doTryCatch(return(expr), name, parentenv, handler)
#>
#> [[47]]
#> fun(libname, pkgname)
#>
#> [[48]]
#> showtextdb::load_showtext_fonts()
#>
#> [[49]]
#> load_user_fonts()
#>
#> [[50]]
#> do.call(sysfonts::font_add, args)
#>
#> [[51]]
#> (function(family,
#> regular,
#> bold = NULL,
#> italic = NULL,
#> bolditalic = NULL,
#> symbol = NULL)
#> {
#> family = as.character(family)[1]
#>
#> # Shouldn't modify default fonts
#> if((family %in% c("sans", "serif", "mono")) &&
#> (all(c("sans", "serif", "mono") %in% font_families())))
#> stop("default font families ('sans', 'serif', 'mono') cannot be modified")
#>
#> # The maximum length for font family name is 200 bytes
#> if(nchar(family, type = "bytes") > 200)
#> stop("family name is too long (max 200 bytes)")
#>
#> r = .Call("load_font", check_font_path(regular, "regular"), PACKAGE = "sysfonts");
#>
#> # If other font faces are not specified, use the regular one
#> b = if(is.null(bold)) r
#> else .Call("load_font", check_font_path(bold, "bold"), PACKAGE = "sysfonts");
#>
#> i = if(is.null(italic)) r
#> else .Call("load_font", check_font_path(italic, "italic"), PACKAGE = "sysfonts");
#>
#> bi = if(is.null(bolditalic)) r
#> else .Call("load_font", check_font_path(bolditalic, "bolditalic"), PACKAGE = "sysfonts");
#>
#> s = if(is.null(symbol)) r
#> else .Call("load_font", check_font_path(symbol, "symbol"), PACKAGE = "sysfonts");
#>
#> lst = .pkg.env$.font.list
#> new_family = list(regular = r, bold = b, italic = i, bolditalic = bi, symbol = s)
#> lst[[family]] = new_family
#> .pkg.env$.font.list = lst
#> .pkg.env$.font.list.all = c(.pkg.env$.font.list.all, new_family)
#>
#> invisible(font_families())
#> })(family = "source-han-serif-cn", regular = NULL, bold = NULL,
#> italic = NULL, bolditalic = NULL, symbol = NULL)
#>
#> [[52]]
#> r = .Call("load_font", check_font_path(regular, "regular"), PACKAGE = "sysfonts")
#>
#> [[53]]
#> tryCatch(file.exists(path), error = function(e) {
#> print(path)
#> print(sys.calls())
#> })
#>
#> [[54]]
#> tryCatchList(expr, classes, parentenv, handlers)
#>
#> [[55]]
#> tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>
#> [[56]]
#> value[[3L]](cond)
#> Error: package or namespace load failed for 'showtext':
#> .onLoad failed in loadNamespace() for 'showtext', details:
#> call: file.exists(path)
#> error: invalid 'file' argument
sessionInfo()
#> R version 3.6.3 (2020-02-29)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: CentOS Linux 8 (Core)
#>
#> Matrix products: default
#> BLAS: /opt/R/R-3.6.3/lib64/R/lib/libRblas.so
#> LAPACK: /opt/R/R-3.6.3/lib64/R/lib/libRlapack.so
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] showtextdb_2.0 sysfonts_0.8.1
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.4.10 digest_0.6.25 magrittr_1.5 evaluate_0.14
#> [5] highr_0.8 rlang_0.4.6 stringi_1.4.6 rmarkdown_2.1.3
#> [9] tools_3.6.3 stringr_1.4.0 xfun_0.14 yaml_2.2.1
#> [13] compiler_3.6.3 htmltools_0.4.0 knitr_1.28.5
<sup>Created on 2020-05-30 by the reprex package (v0.3.0)</sup>
路径确实是 NULL 传进来,然后开始报错