R包rsvg安装失败求助:两种安装方法均出现报错
解决rsvg包安装依赖下载超时问题
问题描述
尝试安装R包rsvg失败,两种安装方式均因下载rsvg-2.48.8依赖库超时,导致编译失败:
方法1:使用install.packages("rsvg")
install.packages("rsvg") Installing package into ‘C:/Users/hp/AppData/Local/R/win-library/4.2’ (as ‘lib’ is unspecified) There is a binary version available but the source version is later: binary source needs_compilation rsvg 2.3.1 2.3.2 TRUE installing the source package ‘rsvg’ trying URL 'https://cloud.r-project.org/src/contrib/rsvg_2.3.2.tar.gz' Content type 'application/x-gzip' length 183798 bytes (179 KB) downloaded 179 KB * installing *source* package 'rsvg' ... ** package 'rsvg' successfully unpacked and MD5 sums checked ** using staged installation ** libs rm -f rsvg.dll rsvg.o "C:/PROGRA~1/R/R-42~1.1/bin/x64/Rscript.exe" "../tools/winlibs.R" 2.48.8 Error in download.file(sprintf("https://github.com/rwinlib/rsvg/archive/v%s.zip", : download from 'https://github.com/rwinlib/rsvg/archive/v2.48.8.zip' failed In addition: Warning message: In download.file(sprintf("https://github.com/rwinlib/rsvg/archive/v%s.zip", : URL 'https://codeload.github.com/rwinlib/rsvg/zip/refs/tags/v2.48.8': Timeout of 60 seconds was reached Execution halted make: *** [Makevars.win:7: winlibs] Error 1 ERROR: compilation failed for package 'rsvg' * removing 'C:/Users/hp/AppData/Local/R/win-library/4.2/rsvg' The downloaded source packages are in ‘C:\Users\hp\AppData\Local\Temp\RtmpmG8xM2\downloaded_packages’ Warning message: In install.packages("rsvg") : installation of package ‘rsvg’ had non-zero exit status
方法2:使用remotes::install_github("ropensci/rsvg")
library(remotes) install_github("ropensci/rsvg") Downloading GitHub repo ropensci/rsvg@HEAD ✔ checking for file 'C:\Users\hp\AppData\Local\Temp\RtmpmG8xM2\remotes5a645f9057ed\ropensci-rsvg-6d9840f/DESCRIPTION' ─ preparing 'rsvg': checking DESCRIPTION meta-information ... checking DESCRIPTION meta-information ... ✔ checking DESCRIPTION meta-information ─ cleaning src ─ checking for LF line-endings in source and make files and shell scripts ─ checking for empty or unneeded directories ─ building 'rsvg_2.3.2.tar.gz' Warning: Warning: file 'rsvg/cleanup' did not have execute permissions: corrected Warning: file 'rsvg/configure' did not have execute permissions: corrected Installing package into ‘C:/Users/hp/AppData/Local/R/win-library/4.2’ (as ‘lib’ is unspecified) * installing *source* package 'rsvg' ... ** using staged installation ** libs rm -f rsvg.dll rsvg.o "C:/PROGRA~1/R/R-42~1.1/bin/x64/Rscript.exe" "../tools/winlibs.R" 2.48.8 Error in download.file(sprintf("https://github.com/rwinlib/rsvg/archive/v%s.zip", : download from 'https://github.com/rwinlib/rsvg/archive/v2.48.8.zip' failed In addition: Warning messages: 1: In download.file(sprintf("https://github.com/rwinlib/rsvg/archive/v%s.zip", : downloaded length 35551249 != reported length 43111940 2: In download.file(sprintf("https://github.com/rwinlib/rsvg/archive/v%s.zip", : URL 'https://codeload.github.com/rwinlib/rsvg/zip/refs/tags/v2.48.8': Timeout of 60 seconds was reached Execution halted make: *** [Makevars.win:7: winlibs] Error 1 ERROR: compilation failed for package 'rsvg' * removing 'C:/Users/hp/AppData/Local/R/win-library/4.2/rsvg' Warning message: In i.p(...) : installation of package ‘C:/Users/hp/AppData/Local/Temp/RtmpmG8xM2/file5a645596780/rsvg_2.3.2.tar.gz’ had non-zero exit status
会话信息
sessionInfo() R version 4.2.1 (2022-06-23 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22000) Matrix products: default locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C LC_TIME=English_United States.utf8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] remotes_2.4.2 loaded via a namespace (and not attached): [1] processx_3.8.0 compiler_4.2.1 R6_2.5.1 rprojroot_2.0.3 cli_3.4.1 prettyunits_1.1.1 tools_4.2.1 withr_2.5.0 [9] curl_4.3.3 crayon_1.5.2 callr_3.7.2 ps_1.7.2 pkgbuild_1.3.1
解决方法
1. 安装预编译二进制版本
直接使用已编译好的二进制包,跳过源码编译和依赖下载步骤:
install.packages("rsvg", type = "binary")
该版本为2.3.1,比源码版2.3.2稍旧,但功能可满足大部分场景需求。
2. 延长下载超时时间
修改R的下载超时参数,给依赖库下载预留足够时间:
# 设置超时为300秒(5分钟) options(timeout = 300) # 重新尝试官方源安装 install.packages("rsvg") # 或重新尝试GitHub安装 remotes::install_github("ropensci/rsvg")
3. 手动放置依赖库
手动获取对应版本的依赖压缩包,放置到R的依赖目录,跳过编译时的自动下载:
- 找到R的winlibs目录,通常路径为
C:\Users\hp\AppData\Local\R\win-library\4.2\winlibs,不存在则手动创建 - 将
rsvg-2.48.8的压缩包解压到该目录,确保解压后的文件夹名为rsvg-2.48.8 - 重新运行安装命令
4. 使用pak包安装
pak包具备更可靠的下载重试机制,可有效解决超时问题:
# 先安装pak install.packages("pak") # 使用pak安装rsvg pak::pkg_install("rsvg")
内容的提问来源于stack exchange,提问作者MYaseen208
相关产品推荐
相关产品推荐

