Error installing Rcpp from Posit Package Manager

I'm not sure if this is a Posit Package Manager issue or an renv issue, but when I try to install Rcpp using renv 1.1.4 on MacOS, it is attempting to install Rcpp 1.3 instead of 1.0.14, and then errors with ERROR: a 'NAMESPACE' file is required. While renv::install('Rcpp') errors out, I can get a successful installation with renv::install('Rcpp@1.0.14').

The version numbers for Rcpp on Posit Package Manager look odd, where I see 1.3 as an archived version, but the latest version number appears lower at 1.0.14. I don't see version 1.3 when I look at the CRAN archive here: Index of /src/contrib/Archive/Rcpp. Maybe this is the source of the issue.

> renv::install('Rcpp')
# Downloading packages -------------------------------------------------------
- Downloading Rcpp from CRAN ...                OK [file is up to date]
Successfully downloaded 1 package in 41 milliseconds.

The following package(s) will be installed:
- Rcpp [1.3]
These packages will be installed into "~/Downloads/temp/test-rmysql/renv/library/macos/R-4.4/aarch64-apple-darwin20".

Do you want to proceed? [Y/n]: Y

# Installing packages --------------------------------------------------------
- Installing Rcpp ...                           FAILED
Error: Error installing package 'Rcpp':
================================

* installing *source* package ‘Rcpp’ ...
** using staged installation
checking for C++ compiler default output... a.out
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -arch arm64 -std=gnu++17 accepts -g... yes
rm: conftest.dSYM: is a directory
checking how to run the C++ preprocessor... clang++ -arch arm64 -std=gnu++17 -E
Building MyLib in inst/lib...
clang++ -arch arm64 -std=gnu++17 -falign-functions=64 -Wall -g -O2 -I/opt/R/arm64/include -I/opt/homebrew/include -I../inst/lib  -c -o Adder.o Adder.cpp
clang++ -arch arm64 -std=gnu++17 -falign-functions=64 -Wall -g -O2 -I/opt/R/arm64/include -I/opt/homebrew/include -I../inst/lib  -c -o Multiplier.o Multiplier.cpp
ar r libMyLib.a Adder.o Multiplier.o
ar: creating archive libMyLib.a
ranlib libMyLib.a
Copying source files to inst/doc...
configure: creating ./config.status
config.status: creating src/Makevars
ERROR: a 'NAMESPACE' file is required
* removing ‘/Users/lmendelowitz/Downloads/temp/test-rmysql/renv/staging/1/Rcpp’
install of package 'Rcpp' failed [error code 1]
Traceback (most recent calls last):
12: renv::install("Rcpp")
11: renv_install_impl(records) at install.R#250
10: if (staged)
      renv_install_staged(records)
    else
      renv_install_default(records) at install.R#294
 9: renv_install_default(records) at install.R#314
 8: handler(package, renv_install_package(record)) at install.R#417
 7: handler(package, renv_install_package(record)) at install.R#417
 6: withCallingHandlers(
      renv_install_package_impl(record),
      error = function(e) writef("FAILED")
    ) at install.R#450
 5: withCallingHandlers(
      renv_install_package_impl(record),
      error = function(e) writef("FAILED")
    ) at install.R#450
 4: if (copyable)
      renv_file_copy(path, installpath, overwrite = TRUE)
    else
      r_cmd_install(package, path) at install.R#661
 3: if (!identical(status, 0L))
      r_exec_error(package, output, "install", status) at r.R#234
 2: abort(all) at r.R#52
 1: stop(fallback) at abort.R#44
> sessionInfo()
R version 4.4.3 (2025-02-28)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.5

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base

loaded via a namespace (and not attached):
[1] compiler_4.4.3 tools_4.4.3    renv_1.1.3
> options('repos')
$repos
                                         CRAN
"https://packagemanager.posit.co/cran/latest"
> renv::diagnostics()
Diagnostics Report [renv 1.1.3]
===============================


# Session Info ---------------------------------------------------------------
R version 4.4.3 (2025-02-28)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.5

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base

loaded via a namespace (and not attached):
[1] compiler_4.4.3 tools_4.4.3    renv_1.1.3

# Project --------------------------------------------------------------------
Project path: "~/Downloads/temp/test-rmysql"

# Status ---------------------------------------------------------------------
No issues found -- the project is in a consistent state.

# Packages -------------------------------------------------------------------
           Library Source Lockfile Source Path Dependency
KernSmooth 2.23-26   CRAN     <NA>   <NA>  [2]       <NA>
MASS        7.3-64   CRAN     <NA>   <NA>  [2]       <NA>
Matrix       1.7-2   CRAN     <NA>   <NA>  [2]       <NA>
Rcpp        1.0.14   RSPM     <NA>   <NA>  [1]       <NA>
boot        1.3-31   CRAN     <NA>   <NA>  [2]       <NA>
class       7.3-23   CRAN     <NA>   <NA>  [2]       <NA>
cluster      2.1.8   CRAN     <NA>   <NA>  [2]       <NA>
codetools   0.2-20   CRAN     <NA>   <NA>  [2]       <NA>
foreign     0.8-88   CRAN     <NA>   <NA>  [2]       <NA>
lattice     0.22-6   CRAN     <NA>   <NA>  [2]       <NA>
mgcv         1.9-1   CRAN     <NA>   <NA>  [2]       <NA>
nlme       3.1-167   CRAN     <NA>   <NA>  [2]       <NA>
nnet        7.3-20   CRAN     <NA>   <NA>  [2]       <NA>
renv         1.1.3   RSPM    1.1.3   RSPM  [1]     direct
rpart       4.1.24   CRAN     <NA>   <NA>  [2]       <NA>
spatial     7.3-18   CRAN     <NA>   <NA>  [2]       <NA>
survival     3.8-3   CRAN     <NA>   <NA>  [2]       <NA>
utils         <NA>   <NA>     <NA>   <NA>  [2]   indirect

[1]: /Users/lmendelowitz/Downloads/temp/test-rmysql/renv/library/macos/R-4.4/aarch64-apple-darwin20
[2]: /Users/lmendelowitz/Library/Caches/org.R-project.R/R/renv/sandbox/macos/R-4.4/aarch64-apple-darwin20/f7156815


# ABI ------------------------------------------------------------------------
- No ABI problems were detected in the set of installed packages.

# User Profile ---------------------------------------------------------------
[1] Source  Package Require Version Dev
<0 rows> (or 0-length row.names)

# Settings -------------------------------------------------------------------
List of 13
 $ bioconductor.version     : NULL
 $ external.libraries       : chr(0)
 $ ignored.packages         : chr(0)
 $ package.dependency.fields: chr [1:3] "Imports" "Depends" "LinkingTo"
 $ ppm.enabled              : NULL
 $ ppm.ignored.urls         : chr(0)
 $ r.version                : NULL
 $ snapshot.type            : chr "implicit"
 $ use.cache                : logi TRUE
 $ vcs.ignore.cellar        : logi TRUE
 $ vcs.ignore.library       : logi TRUE
 $ vcs.ignore.local         : logi TRUE
 $ vcs.manage.ignores       : logi TRUE

# Options --------------------------------------------------------------------
List of 9
 $ defaultPackages                     : chr [1:6] "datasets" "utils" "grDevices" "graphics" ...
 $ download.file.method                : NULL
 $ download.file.extra                 : NULL
 $ install.packages.compile.from.source: chr "interactive"
 $ pkgType                             : chr "both"
 $ repos                               : Named chr "https://packagemanager.posit.co/cran/latest"
  ..- attr(*, "names")= chr "CRAN"
 $ renv.consent                        : logi TRUE
 $ renv.project.path                   : chr "/Users/lmendelowitz/Downloads/temp/test-rmysql"
 $ renv.verbose                        : logi TRUE

# Environment Variables ------------------------------------------------------
HOME                        = /Users/lmendelowitz
LANG                        = en_US.UTF-8
MAKE                        = make
R_LIBS                      = <NA>
R_LIBS_SITE                 = /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/site-library
R_LIBS_USER                 = /Users/lmendelowitz/Downloads/temp/test-rmysql/renv/library/macos/R-4.4/aarch64-apple-darwin20
RENV_DEFAULT_R_ENVIRON      = <NA>
RENV_DEFAULT_R_ENVIRON_USER = <NA>
RENV_DEFAULT_R_LIBS         = <NA>
RENV_DEFAULT_R_LIBS_SITE    = /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/site-library
RENV_DEFAULT_R_LIBS_USER    = /Users/lmendelowitz/Library/R/arm64/4.4/library
RENV_DEFAULT_R_PROFILE      = <NA>
RENV_DEFAULT_R_PROFILE_USER = <NA>
RENV_PATHS_CELLAR           = /Users/lmendelowitz/renv_local_sources
RENV_PATHS_LOCAL            = /Users/lmendelowitz/renv_local_sources
RENV_PROJECT                = /Users/lmendelowitz/Downloads/temp/test-rmysql

# PATH -----------------------------------------------------------------------
- /Users/lmendelowitz/perl5/bin
- /Users/lmendelowitz/.pyenv/plugins/pyenv-virtualenv/shims
- /Users/lmendelowitz/.pyenv/shims
- /Users/lmendelowitz/.pyenv/bin
- /Users/lmendelowitz/.rbenv/shims
- /usr/local/opt/gnu-sed/libexec/gnubin
- /opt/homebrew/opt/findutils/libexec/gnubin
- /Users/lmendelowitz/.local/bin
- /opt/homebrew/bin
- /opt/homebrew/sbin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/TeX/texbin
- /Users/lmendelowitz/perl5/bin
- /Users/lmendelowitz/.pyenv/plugins/pyenv-virtualenv/shims
- /Users/lmendelowitz/.pyenv/bin
- /Users/lmendelowitz/.rbenv/shims
- /usr/local/opt/gnu-sed/libexec/gnubin
- /opt/homebrew/opt/findutils/libexec/gnubin
- /Users/lmendelowitz/.local/bin
- /opt/homebrew/bin
- /opt/homebrew/sbin
- /opt/homebrew/opt/fzf/bin

# Cache ----------------------------------------------------------------------
There are a total of 626 packages installed in the renv cache.
Cache path: "~/Library/Caches/org.R-project.R/R/renv/cache/v5/macos/R-4.4/aarch64-apple-darwin20"

@greg Are you able to help out with this one? I keep running into this issue, and you were very helpful with a previous issue I had with the public Posit Package Manager which I posted here. Thanks in advance for the help!

Hey @Lmendy, thanks for the report. Those odd Rcpp versions 1.1/1.2/1.3 showing in the archive in Posit Package Manager is a known issue, but we hadn't seen any actual user impact until now. Those versions are actually legitimate Rcpp packages, but from a super old iteration of Rcpp that had been removed from CRAN long ago. They should definitely be removed though, but we just haven't gotten around to it yet.

For the renv issue, I tested a renv::install("Rcpp") with renv 1.1.4 on macOS, R 4.5, and can't reproduce. I'm still getting the latest actual Rcpp 1.0.14 version that's listed in PACKAGES.

> options(repos = "https://p3m.dev/cran/latest")
> install.packages("renv")
trying URL 'https://p3m.dev/cran/latest/bin/macosx/big-sur-arm64/contrib/4.5/renv_1.1.4.tgz'
Content type 'binary/octet-stream' length 2309241 bytes (2.2 MB)
==================================================
downloaded 2.2 MB


The downloaded binary packages are in
/var/folders/ml/4pc8nz755db_40h56sry7cqm0000gp/T//RtmpFkLGgT/downloaded_packages
> renv::install("Rcpp")
# Downloading packages -------------------------------------------------------
- Downloading Rcpp from https://p3m.dev/cran/latest ... OK [2.1 Mb in 0.68s]
Successfully downloaded 1 package in 3.6 seconds.

The following package(s) will be installed:
- Rcpp [1.0.14]
These packages will be installed into "/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library".

Do you want to proceed? [Y/n]: 

Any idea on what else I might have to do to reproduce?

@greg This issue is occurring with renv 1.1.3 (I shared the wrong version in my initial report) and I can reproduce it with these steps. Using renv 1.1.4 does not have this issue, however we currently stuck on renv 1.1.3 due to a regression in renv 1.1.4 that broke our docker build process.

options(repos = "https://p3m.dev/cran/latest")

# Install renv
install.packages("renv")

# Initialize renv project and downgrade to renv 1.1.3
renv::init()
renv::install("renv@1.1.3")

# Restart R session to load renv 1.1.3

renv::install("Rcpp") # This fails and tries to install Rcpp 1.3

Here's the output:

❯ R

R version 4.4.3 (2025-02-28) -- "Trophy Case"
Copyright (C) 2025 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

renv 1.1.3 was loaded from project library, but this project is configured to use renv 1.1.4.
- Use `renv::record("renv@1.1.3")` to record renv 1.1.3 in the lockfile.
- Use `renv::restore(packages = "renv")` to install renv 1.1.4 into the project library.
- Project '~/Downloads/temp/test-rcpp' loaded. [renv 1.1.3]
- The project is out-of-sync -- use `renv::status()` for details.
> renv::install("Rcpp")
# Downloading packages -------------------------------------------------------
- Querying repositories for available binary packages ... Done!
- Querying repositories for available source packages ... Done!
- Downloading Rcpp from https://p3m.dev/cran/latest ... OK [file is up to date]
Successfully downloaded 1 package in 3.9 seconds.

The following package(s) will be installed:
- Rcpp [1.3]
These packages will be installed into "~/Downloads/temp/test-rcpp/renv/library/macos/R-4.4/aarch64-apple-darwin20".

Do you want to proceed? [Y/n]: Y

# Installing packages --------------------------------------------------------
- Installing Rcpp ...                           FAILED
Error: Error installing package 'Rcpp':
================================

* installing *source* package ‘Rcpp’ ...
** using staged installation
checking for C++ compiler default output... a.out
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -arch arm64 -std=gnu++17 accepts -g... yes
rm: conftest.dSYM: is a directory
checking how to run the C++ preprocessor... clang++ -arch arm64 -std=gnu++17 -E
Building MyLib in inst/lib...
clang++ -arch arm64 -std=gnu++17 -falign-functions=64 -Wall -g -O2 -I/opt/R/arm64/include -I/opt/homebrew/include -I../inst/lib  -c -o Adder.o Adder.cpp
clang++ -arch arm64 -std=gnu++17 -falign-functions=64 -Wall -g -O2 -I/opt/R/arm64/include -I/opt/homebrew/include -I../inst/lib  -c -o Multiplier.o Multiplier.cpp
ar r libMyLib.a Adder.o Multiplier.o
ar: creating archive libMyLib.a
ranlib libMyLib.a
Copying source files to inst/doc...
configure: creating ./config.status
config.status: creating src/Makevars
ERROR: a 'NAMESPACE' file is required
* removing ‘/Users/lmendelowitz/Downloads/temp/test-rcpp/renv/staging/1/Rcpp’
install of package 'Rcpp' failed [error code 1]
Traceback (most recent calls last):
12: renv::install("Rcpp")
11: renv_install_impl(records) at install.R#250
10: if (staged)
      renv_install_staged(records)
    else
      renv_install_default(records) at install.R#294
 9: renv_install_default(records) at install.R#314
 8: handler(package, renv_install_package(record)) at install.R#417
 7: handler(package, renv_install_package(record)) at install.R#417
 6: withCallingHandlers(
      renv_install_package_impl(record),
      error = function(e) writef("FAILED")
    ) at install.R#450
 5: withCallingHandlers(
      renv_install_package_impl(record),
      error = function(e) writef("FAILED")
    ) at install.R#450
 4: if (copyable)
      renv_file_copy(path, installpath, overwrite = TRUE)
    else
      r_cmd_install(package, path) at install.R#661
 3: if (!identical(status, 0L))
      r_exec_error(package, output, "install", status) at r.R#234
 2: abort(all) at r.R#52
 1: stop(fallback) at abort.R#44
>

Why not

renv::install("Rcpp@1.0.14")

IMHO using renv while pointing to the latest CRAN snapshot and NOT using any versioning constraints for renv::install() I don't think is good practice. I'd strongly recommend either to create a renv.lock file and restore from there or always use renv::install() with versioning attached. Both approaches will considerably reduce the risk for issues such as you experience.

@michaelmayer Thanks for the suggestion. This provides a good workaround and is what we've been doing, but the situation is still a little unfriendly to our analyst team who have less expertise with using renv.

This came up in the context of an analyst project where Rcpp is being installed because it is a dependency of another package. So the analysts I am working with are doing renv::install("otherPackage"), which then tries to install Rcpp 1.3 automatically, and then that install fails with renv@1.1.3 unless you explicitly call renv::install("Rcpp@1.0.14") first.

I kind of agree with your general sentiment but also would maintain the perspective that using renv::install("otherPackage") with the CRAN repository set to latest but NOT specifying a package version is an anti-pattern which I almost tend to call bad practice. Why do you want to expose yourself to the intricacies of renv when (by not specifying a package version or using a lock file) you are up for pot luck of which version of a Package you will get ?

If you wanted to make slightly better use of renv, I would recommend to convert your projects to use renv.lock files and then - instead of individually using renv::install("package@version") - you simply could run renv::restore() and all packages would be restored from renv.lock (cf. Restore project library from a lockfile — restore • renv)

Alternatively, if the renv::install("packageName") (without version) is already established standard practice in your organisation, I still encourage you to use a defined time-based snapshot other than latest as CRAN repository, e.g. options(repos="https://p3m.dev/cran/2025-06-16") to make CRAN appear as it was on June 16th, 2025. Effectively this will then also fix the package versions.

Thanks for the note on the best practices @michaelmayer. I think we are somewhat in line with the best practices you are suggesting (more context on that below).

However, I still think this should be addressed at some point by removing the bad Rcpp packages from Posit Package Manager because renv calls will still error when using renv@1.1.3, such as calling renv::update() on a project that has a good renv.lock file and is using options(repos="https://p3m.dev/cran/2025-06-16") which will try to install Rcpp@1.3:

- Project '~/Downloads/temp/test-renv' loaded. [renv 1.1.3]
> options(repos="https://p3m.dev/cran/2025-06-16")
> renv::update()
- Querying repositories for available binary packages ... Done!
- Querying repositories for available source packages ... Done!
- Checking for updated packages ... Done!
The following package(s) will be updated:

# CRAN -----------------------------------------------------------------------
- lattice   [0.22-6 -> 0.22-7]
- MASS      [7.3-64 -> 7.3-65]
- Matrix    [1.7-2 -> 1.7-3]
- mgcv      [1.9-1 -> 1.9-3]
- nlme      [3.1-167 -> 3.1-168]
- renv      [repo: RSPM -> CRAN; ver: 1.1.3 -> 1.1.4]

# Repository -----------------------------------------------------------------
- Rcpp      [repo: RSPM -> *; ver: 1.0.14 -> 1.3]

Do you want to proceed? [Y/n]:

I just found the renv GitHub issue related to this - a workaround that was built into renv to address this p3m.dev Rcpp issue here: `renv` 1.1.3 makes up version for packages leading to crash · Issue #2118 · rstudio/renv · GitHub


For full context, we are using renv.lock files on our projects as you suggest. However, we have an in-house R package that we install directly from GitLab with a call like this: renv::install('git::git@gitlab.domain.net:r_d/customPackage.git@1.1.0'), which with renv@1.1.3 might proceed to error when it installs Rcpp@1.3. We explicitly are providing the version of our customPackage, but not for it's Rcpp dependency when initializing a project.

When getting started on a project I typically call:

renv::init()
renv::install('git::git@gitlab.domain.net:r_d/customPackage.git@1.1.0')

since renv::init() initializes the renv.lock but installs the "customPackage" from an unknown source (out of the renv cache), while the explicit install call from gitlab will properly set the "Source": "git" and "RemoteUrl": "git@gitlab.domain.net:r_d/customPackage.git" in the renv.lock, which is what we need in order to restore this renv.lock successfully in our docker build process.

1 Like