RStudio重建R包时Vignette编译失败问题求助
问题:R包重建时Vignette编译失败
错误信息
checking DESCRIPTION meta-information ... ─ installing the package to build vignettes (480ms) E creating vignettes (17.8s) --- re-building 'vignette.rmd' using rmarkdown [WARNING] Deprecated: markdown_github. Use gfm instead. Error: processing vignette 'vignette.rmd' failed with diagnostics: Failed to locate 'weave' output file 'vignette.pdf' or 'vignette.html' for vignette with name 'vignette' and engine 'knitr::rmarkdown'. The following files exist in working directory 'C:\Users\thebi\AppData\Local\Temp\Rtmpsv4tI9\Rbuild75703c815311\monkeyr\vignettes': 'vignette.R' (3764 bytes), 'vignette.md' (5840 bytes), 'vignette.rmd' (6272 bytes) --- failed re-building 'vignette.rmd' SUMMARY: processing the following file failed: 'vignette.rmd' Error: Vignette re-building failed. Execution halted Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`: ! System command 'Rcmd.exe' failed
当前Vignette头部配置
title: "monkeyr" output: md_document: variant: markdown_github vignette: > %\VignetteIndexEntry{monkeyr vignette} %\VignetteEngine{knitr::rmarkdown} \usepackage[utf8]{inputenc} ---
已尝试将markdown_github改为gfm,问题仍存在。
会话信息
R version 4.2.3 (2023-03-15 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045) Matrix products: default locale: [1] LC_COLLATE=English_New Zealand.utf8 LC_CTYPE=English_New Zealand.utf8 LC_MONETARY=English_New Zealand.utf8 [4] LC_NUMERIC=C LC_TIME=English_New Zealand.utf8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] monkeyr_0.1.0 lubridate_1.9.2 ggplot2_3.4.2 hrbrthemes_0.8.0 fontawesome_0.5.1 magrittr_2.0.3 [7] dplyr_1.1.2 knitr_1.43 rmarkdown_2.22 devtools_2.4.5 usethis_2.2.2 loaded via a namespace (and not attached): [1] backports_1.4.1 systemfonts_1.0.4 lazyeval_0.2.2 splines_4.2.3 [5] sp_1.6-1 jqr_1.2.3 digest_0.6.31 flexdashboard_0.6.1 [9] htmltools_0.5.5 viridis_0.6.3 formattable_0.2.1 ggpmisc_0.5.2 [13] fansi_1.0.4 checkmate_2.2.0 memoise_2.0.1 tzdb_0.4.0 [17] remotes_2.4.2 readr_2.1.4 extrafont_0.19 extrafontdb_1.0 [21] svglite_2.1.1 timechange_0.2.0 gfonts_0.2.0 prettyunits_1.1.1 [25] colorspace_2.1-0 lutz_0.3.1 rvest_1.0.3 ggrepel_0.9.3 [29] xfun_0.39 rgdal_1.6-7 callr_3.7.3 crayon_1.5.2 [33] jsonlite_1.8.5 roxygen2_7.2.3 survival_3.5-3 zoo_1.8-12 [37] countrycode_1.5.0 glue_1.6.2 kableExtra_1.3.4 gtable_0.3.3 [41] webshot_0.5.4 MatrixModels_0.5-1 pkgbuild_1.4.2 unikn_0.8.0 [45] Rttf2pt1_1.3.12 maps_3.4.1 fontquiver_0.2.1 SparseM_1.81 [49] scales_1.2.1 DBI_1.1.3 miniUI_0.1.1.1 Rcpp_1.0.10 [53] viridisLite_0.4.2 xtable_1.8-4 units_0.8-2 proxy_0.4-27 [57] fontLiberation_0.1.0 profvis_0.3.8 htmlwidgets_1.6.2 httr_1.4.6 [61] RColorBrewer_1.1-3 ellipsis_0.3.2 urlchecker_1.0.1 pkgconfig_2.0.3 [65] sass_0.4.6 janitor_2.2.0 crul_1.4.0 utf8_1.2.3 [69] tidyselect_1.2.0 rlang_1.1.1 ggspatial_1.1.8 later_1.3.1 [73] polynom_1.4-1 munsell_0.5.0 tools_4.2.3 cachem_1.0.8 [77] cli_3.6.1 generics_0.1.3 evaluate_0.21 stringr_1.5.0 [81] fastmap_1.1.1 yaml_2.3.7 ggpp_0.5.2 processx_3.8.1 [85] fs_1.6.2 pixiedust_0.9.1 purrr_1.0.1 reactable_0.4.4 [89] mime_0.12 quantreg_5.95 xml2_1.3.4 brio_1.1.3 [93] compiler_4.2.3 rstudioapi_0.14 plotly_4.10.2 curl_5.0.1 [97] e1071_1.7-13 testthat_3.2.0 mapdata_2.3.1 tibble_3.2.1 [101] nord_1.0.0 bslib_0.5.0 stringi_1.7.12 ps_1.7.5 [105] desc_1.4.2 gdtools_0.3.3 forcats_1.0.0 logger_0.2.2 [109] lattice_0.20-45 Matrix_1.5-3 commonmark_1.9.0 fontBitstreamVera_0.1.1 [113] classInt_0.4-9 vctrs_0.6.2 pillar_1.9.0 lifecycle_1.0.3 [117] lmtest_0.9-40 jquerylib_0.1.4 data.table_1.14.8 cowplot_1.1.1 [121] httpuv_1.6.11 R6_2.5.1 promises_1.2.0.1 KernSmooth_2.23-20 [125] gridExtra_2.3 sessioninfo_1.2.2 distill_1.5 MASS_7.3-58.2 [129] pkgload_1.3.3 rprojroot_2.0.3 httpcode_0.3.0 withr_2.5.0 [133] hms_1.1.3 geojson_0.3.4 udunits2_0.13.2.1 grid_4.2.3 [137] tidyr_1.3.0 class_7.3-21 snakecase_0.11.0 downlit_0.4.2 [141] ggnewscale_0.4.9 sf_1.0-13 shiny_1.7.4
解决思路
- 调整Vignette输出格式:R包vignette要求生成PDF或HTML格式,当前配置仅输出MD文件,不符合规则。修改输出为
html_document或pdf_document,示例:
若需保留MD输出,可添加多格式配置,但必须包含PDF或HTML:title: "monkeyr" output: html_document vignette: > %\VignetteIndexEntry{monkeyr vignette} %\VignetteEngine{knitr::rmarkdown} \usepackage[utf8]{inputenc} ---output: html_document: default md_document: variant: gfm - 更新依赖包版本:当前使用的knitr_1.43和rmarkdown_2.22版本较旧,更新到最新版本尝试解决兼容性问题:
update.packages(c("knitr", "rmarkdown")) - 清理临时缓存:R包构建的临时目录可能存在缓存冲突,重启RStudio后重新构建,或手动清理系统临时文件。
- 检查DESCRIPTION配置:确保DESCRIPTION文件中添加
VignetteBuilder: knitr字段,明确指定vignette构建工具。 - 单独测试编译:直接在本地编译vignette文件,排查是否是代码本身的问题:
rmarkdown::render("vignettes/vignette.rmd", output_format = "html_document")
内容的提问来源于stack exchange,提问作者monkey
相关产品推荐
相关产品推荐

