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

部署依赖pcaMethods的RShiny应用至RStudio Connect遇版本错误求助

解决RShiny发布到RStudio Connect时的包版本不可用错误

问题详情

发布RShiny应用到RStudio Connect时触发错误:

'A required R package was found in the package repository, but the specified version is not available.'

已尝试配置客户端使用Connect可访问的HTTP(S)包仓库,重新安装受影响包后重新发布,但问题未解决。错误日志如下:

[Connect] 2023/02/06 21:08:00.134251192 curl: HTTP 404 https://bioconductor.org/packages/3.16/bioc/src/contrib/Archive/pcaMethods/pcaMethods_1.88.0.tar.gz
GET /__api__/tasks/mBCmiDx3xoVyy0wY?first_status=359 9ms
[Connect] 2023/02/06 21:08:01.137834919 FAILED
[Connect] 2023/02/06 21:08:01.138457950 Error in getSourceForPkgRecord(pkgRecord, srcDir(project), availablePackagesSource(repos = repos), : Failed to retrieve package sources for pcaMethods 1.88.0 from CRAN (internet connectivity issue?) [1.90.0 is current]
[Connect] 2023/02/06 21:08:01.138490463 
[Connect] 2023/02/06 21:08:01.138539531 Unable to fully restore the R packages associated with this deployment.
[Connect] 2023/02/06 21:08:01.138544607 Please review the preceding messages to determine which package
[Connect] 2023/02/06 21:08:01.138557619 encountered installation difficulty and the cause of the failure.
[Connect] 2023/02/06 21:08:01.141367007 Warning message:
[Connect] 2023/02/06 21:08:01.141479571 In packrat::restore(overwrite.dirty = TRUE, prompt = FALSE, restart = FALSE) :
[Connect] 2023/02/06 21:08:01.141484660   The most recent snapshot was generated using R version 4.2.1
[Connect] 2023/02/06 21:08:01.138683504 Error code: r-package-version-not-available
[Connect] A required R package was found in the package repository, but the specified version is not available.
[Connect] Possible causes:
[Connect] * The client computer that published the content is using a different package repository from the Connect server, and the package repository that Connect is using does not have the requested version of the package.
[Connect] * The Connect server is using a CRAN mirror that is out of date.
[Connect] * The package repository moved to a new URL after the content was published, and Connect is now attempting to rebuild the environment using the old package repository URL.
[Connect] 
[Connect] Possible solutions:
[Connect] * Configure the client with a package repository that is accessible via http(s) from the Connect server, such as CRAN or RStudio Package Manager. Reinstall the affected packages from the new repository and publish the content again.
[Connect] * Update the packages on the CRAN mirror.
  - If this is a local instance of RStudio Package Manager, see the Package Manager documentation for instructions on how to update the mirrored packages.
  - If this is a public CRAN mirror, it may be experiencing technical problems. Choose a different CRAN mirror.
[Connect] 
[Connect] References:
[Connect] * https://docs.rstudio.com/rspm/admin/repositories/#sync-schedule
[Connect] * https://docs.rstudio.com/rspm/admin/appendix/airgapped-installs/#air-gapped-updates
[Connect] * https://support.rstudio.com/hc/en-us/articles/360004067074-Managing-Packages-with-RStudio           
[Connect] 
[Connect] 2023/02/06 21:08:01.138683504 Additional data:
[Connect] Repository: 'CRAN'
[Connect] AvailableVersion: '1.90.0'
[Connect] Package: 'pcaMethods'
[Connect] PackageVersion: '1.88.0'
[Connect] Found in the following log entry:
[Connect] 2023/02/06 21:08:01.138457950 Error in getSourceForPkgRecord(pkgRecord, srcDir(project), availablePackagesSource(repos = repos), : Failed to retrieve package sources for pcaMethods 1.88.0 from CRAN (internet connectivity issue?) [1.90.0 is current]
[Connect] Build error: A required R package was found in the package repository, but the specified version is not available. (r-package-version-not-available)

针对性解决方案

1. 修正包仓库配置,从Bioconductor安装指定版本

日志显示pcaMethods是Bioconductor包,但Connect错误地从CRAN查找。需确保本地和Connect都配置了正确的Bioconductor仓库:

  • 本地R环境中运行以下命令安装指定版本:
    if (!requireNamespace("BiocManager", quietly = TRUE))
        install.packages("BiocManager")
    BiocManager::install(version = "3.16") # 匹配日志中的Bioconductor版本
    BiocManager::install("pcaMethods@1.88.0")
    

2. 对齐R版本

日志提示快照由R 4.2.1生成,需确认Connect服务器的R版本与本地一致。版本不匹配会导致包兼容性问题,可调整本地或服务器的R版本,或验证目标R版本支持pcaMethods_1.88.0。

3. 强制Connect使用Bioconductor仓库

在Shiny项目根目录创建.Rprofile文件,添加仓库配置:

options(repos = c(
  CRAN = "https://cran.rstudio.com/",
  BIOC = "https://bioconductor.org/packages/3.16/bioc/"
))

重新生成包快照后发布:

packrat::snapshot() # 若使用packrat
# 或
renv::snapshot() # 若使用renv

4. 手动上传包到Connect

如果上述方法无效,直接上传包文件到Connect:

  • 下载pcaMethods_1.88.0.tar.gz(对应Bioconductor 3.16归档)
  • 在Connect界面进入「Packages」页面,上传该包
  • 重新发布应用,Connect会优先使用已上传的版本

内容的提问来源于stack exchange,提问作者RanonKahn

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.01 20:11:48