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

自制R包构建安装报错求助:RcppProgress依赖未声明问题

Fixing Installation Error for HACSim R Package (RcppProgress Dependency Issue)

Great question—let's break down what's happening and how to fix it properly.

Core Root Cause of the Error

The warning message spells out exactly the problem: your package's C++ code uses the Rcpp::depends(RcppProgress) attribute (likely in one of your .cpp files), but RcppProgress isn't declared in your DESCRIPTION file.

This violates R's package dependency rules: any package referenced via Rcpp::depends must be listed in either Imports, Depends, or (most appropriately for compiled dependencies) LinkingTo in DESCRIPTION. Without this declaration, R's installer doesn't know it needs to fetch and install RcppProgress alongside your package, leading to the build failure.

Will Sending the .tar.gz Solve This?

Not on its own.

Your local build("HACSim") generates a standardized source package .tar.gz, which is more reliable than a manually zipped folder (it excludes temporary build files and follows R's strict package structure rules). However, if you build the .tar.gz from your current package version (with the missing dependency declaration), your colleague will still hit the same error when installing it.

The dependency issue lives in the package's metadata, regardless of whether it's packaged as a zip or tar.gz.

Step-by-Step Solution

To fix the problem permanently, follow these steps:

  1. Update your DESCRIPTION file
    Add RcppProgress to both the Imports and LinkingTo fields (since it's a compiled dependency used via Rcpp):

    Package: HACSim
    Type: Package
    Title: Iterative simulation of species haplotype accumulation curves
    Version: 1.0
    Date: 2018-04-06
    Author: Jarrett Phillips
    Maintainer: Jarrett Phillips
    Description: Iterative simulation of species haplotype accumulation curves for assessment of sampling completeness
    License: GPL (>= 3)
    NeedsCompilation: Yes
    Imports: ape (>= 5.0), boot (>= 1.3-20), investr (>= 1.4.0), mgcv (>= 1.8-23), pegas (>= 0.10), Rcpp (>= 0.12.16), scam (>= 1.2-2), RcppProgress
    LinkingTo: Rcpp, RcppArmadillo, RcppProgress
    
  2. Re-build the standardized source package
    Run the same build command you used locally to generate a fixed .tar.gz:

    build("HACSim")
    
  3. Share the new .tar.gz with your colleague
    Have them install it using:

    install.packages("path/to/HACSim_1.0.tar.gz", repos = NULL, type = "source")
    

    Alternatively, if they use RStudio, they can go to Tools > Install Packages, select "Package Archive File (.tar.gz)" as the source, and navigate to the file.

Why This Works

  • Adding RcppProgress to LinkingTo tells R that your package needs to link against RcppProgress's compiled libraries during the build process.
  • Adding it to Imports ensures R automatically installs RcppProgress if it's missing on your colleague's system, following best practices for package dependency management.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 09:31:54