自制R包构建安装报错求助:RcppProgress依赖未声明问题
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:
Update your
DESCRIPTIONfile
AddRcppProgressto both theImportsandLinkingTofields (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, RcppProgressRe-build the standardized source package
Run the same build command you used locally to generate a fixed.tar.gz:build("HACSim")Share the new
.tar.gzwith 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
RcppProgresstoLinkingTotells R that your package needs to link against RcppProgress's compiled libraries during the build process. - Adding it to
Importsensures R automatically installs RcppProgress if it's missing on your colleague's system, following best practices for package dependency management.
内容的提问来源于stack exchange,提问作者compbiostats

