You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用devtools::install()安装本地R包时卡在** byte-compile and prepare package for lazy loading阶段的问题求助

devtools::install()安装本地R包时卡在** byte-compile and prepare package for lazy loading阶段的问题求助

我最近在使用devtools::install()安装本地R包时遇到了一个棘手的问题——安装过程卡在了** byte-compile and prepare package for lazy loading这一步,足足等了30多分钟都没进展,最后只能手动终止。我在网上搜了一圈,没找到针对性的解决方案,想问问有没有大佬遇到过类似情况,或者能给点排查思路?

具体情况说明

  • 我的包文件原本放在git仓库的一个非main本地分支里,但后来我把文件移出仓库单独安装,问题依然存在。
  • 完整的控制台输出(已隐去文件路径和包名):
── R CMD build ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

✔  checking for file '<filepath>/DESCRIPTION' (2.1s)

─  preparing '<library name>': (2.5s)

✔  checking DESCRIPTION meta-information (501ms)

─  checking for LF line-endings in source and make files and shell scripts

─  checking for empty or unneeded directories (360ms)

Omitted 'LazyData' from DESCRIPTION

─  building '<library name>.tar.gz'

Running "C:/PROGRA~1/R/R-4.2.2/bin/x64/Rcmd.exe" INSTALL "<filepath>\Temp\Rtmp2nSphm/<library name>.tar.gz" --install-tests

* installing to library '<filepath>/R/win-library/4.2'

* installing *source* package '<library name>' ...

** using staged installation

** R

** byte-compile and prepare package for lazy loading

我的包结构

  • DESCRIPTION
  • NAMESPACE
  • README.md
  • man/:里面是用roxygen2生成的.Rd文件
  • R/:包含多个R脚本,脚本里只有函数外的注释,函数内无多余注释

已尝试的排查/解决操作

  • 确认所有依赖包都已安装
  • 重新安装了devtools
  • 尝试跳过vignettes构建(虽然我的包本身没有vignettes)
  • 使用RStudio的“Check”功能检查包,结果没有给出任何建议,但同样卡在了“checking whether package can be installed”步骤,推测和安装时的问题是同一个。以下是Check功能的输出:
==> devtools::check(document = FALSE)

══ Building ═══════════════════════════════════════════════════════════════════

Setting env vars:

• CFLAGS    : -Wall -pedantic -fdiagnostics-color=always

• CXXFLAGS  : -Wall -pedantic -fdiagnostics-color=always

• CXX11FLAGS: -Wall -pedantic -fdiagnostics-color=always

• CXX14FLAGS: -Wall -pedantic -fdiagnostics-color=always

• CXX17FLAGS: -Wall -pedantic -fdiagnostics-color=always

• CXX20FLAGS: -Wall -pedantic -fdiagnostics-color=always

── R CMD build ────────────────────────────────────────────────────────────────

✔  checking for file '<filepath>\DESCRIPTION' (1.1s)

─  preparing '<library name>': (1.3s)

✔  checking DESCRIPTION meta-information (791ms)

─  checking for LF line-endings in source and make files and shell scripts (687ms)

─  checking for empty or unneeded directories (698ms)

Omitted 'LazyData' from DESCRIPTION

─  building '<library name>.tar.gz'

══ Checking ═══════════════════════════════════════════════════════════════════

Setting env vars:

• _R_CHECK_CRAN_INCOMING_REMOTE_               : FALSE

• _R_CHECK_CRAN_INCOMING_                      : FALSE

• _R_CHECK_FORCE_SUGGESTS_                     : FALSE

• _R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_: FALSE

• NOT_CRAN                                     : true

── R CMD check ────────────────────────────────────────────────────────────────

─  using log directory '<filepath>/<library name>.Rcheck' (1s)

─  using R version 4.2.2 (2022-10-31 ucrt)

─  using platform: x86_64-w64-mingw32 (64-bit)

─  using session charset: UTF-8

─  using options '--no-manual --as-cran' (1.3s)

✔  checking for file '<library name>/DESCRIPTION'

─  checking extension type ... Package

─  this is package '<library name>' version '1.0.0'

─  package encoding: UTF-8 (385ms)

✔  checking package namespace information

✔  checking package dependencies (8.3s)

✔  checking if this is a source package

✔  checking if there is a namespace

✔  checking for executable files (2.3s)

✔  checking for hidden files and directories

✔  checking for portable file names

✔  checking serialization versions

checking whether package '<library name>' can be installed ...

另外补充一下,我的R版本是公司统一部署的4.2.2,没法升级到最新版,不过devtools用的是2.4.5,查了下这个版本是支持R4.2.2的,所以应该不是版本兼容的问题?

备注:内容来源于stack exchange,提问作者Mrob

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 09:03:05