Skip to content

precommit fails to build environment when installing Rcpp #667

@pschloss

Description

@pschloss

Before filing a bug

  • I have installed the latest dev version of {precommit} with remotes::install_github('lorenzwalthert/precommit')
  • I have installed the latest hook revisions (update with precommit::autoupdate())
  • I have installed the latest release of the upstream Python framework pre-comit as described under the update instructions.

Describe the bug

  • On commit, fails to build environment with problems installing Rcpp 1.1.1. Error from logfile copied below
  • Had worked a few weeks ago. Perhaps correlated with update of R to 4.6.0?

Additional context

Perhaps related to #616. Also possibly related to RcppCore/Rcpp#1473? If that's the case, is there a way to have precommit install Rcpp from github rather than CRAN?

  • My operating system is: MacOSX 26.4.1
  • My project uses {renv} : NO
  • the output of `packageVersion('renv'): ‘1.2.2’

cat .cache/pre-commit/pre-commit.log

version information

pre-commit version: 4.6.0
git --version: git version 2.50.1 (Apple Git-155)
sys.version:
    3.14.5 (main, May 10 2026, 10:21:34) [Clang 21.0.0 (clang-2100.0.123.102)]
sys.executable: /opt/homebrew/Cellar/pre-commit/4.6.0/libexec/bin/python3.14
os.name: posix
sys.platform: darwin

error information

An unexpected error has occurred: CalledProcessError: command: ('/Library/Frameworks/R.framework/Resources/bin/Rscript', '--vanilla', '/var/folders/ss/6msy9pqs3556370vh8s084l80000gp/T/tmpa0ef6b36/script.R')
return code: 1
stdout:
    # Bootstrapping renv 1.1.5 ---------------------------------------------------
    - Downloading renv ... OK
    - Installing renv  ... OK
    
    - One or more packages recorded in the lockfile are not installed.
    - Use `renv::status()` for more details.
    The following package(s) will be updated:
    
    # RSPM -----------------------------------------------------------------------
    - backports      [* -> 1.5.0]
    - brew           [* -> 1.0-10]
    - callr          [* -> 3.7.6]
    - cli            [* -> 3.6.5]
    - commonmark     [* -> 2.0.0]
    - cpp11          [* -> 0.5.2]
    - curl           [* -> 7.0.0]
    - desc           [* -> 1.4.3]
    - digest         [* -> 0.6.39]
    - docopt         [* -> 0.7.2]
    - evaluate       [* -> 1.0.5]
    - fs             [* -> 1.6.6]
    - glue           [* -> 1.8.0]
    - here           [* -> 1.0.2]
    - highr          [* -> 0.11]
    - hunspell       [* -> 3.0.6]
    - jsonlite       [* -> 2.0.0]
    - jsonvalidate   [* -> 1.5.0]
    - knitr          [* -> 1.51]
    - lazyeval       [* -> 0.2.2]
    - lifecycle      [* -> 1.0.5]
    - lintr          [* -> 3.3.0-1]
    - magrittr       [* -> 2.0.4]
    - pkgbuild       [* -> 1.4.8]
    - pkgload        [* -> 1.4.1]
    - processx       [* -> 3.8.6]
    - ps             [* -> 1.9.1]
    - purrr          [* -> 1.2.1]
    - R.cache        [* -> 0.17.0]
    - R.methodsS3    [* -> 1.8.2]
    - R.oo           [* -> 1.27.1]
    - R.utils        [* -> 2.13.0]
    - R6             [* -> 2.6.1]
    - Rcpp           [* -> 1.1.1]
    - rex            [* -> 1.2.1]
    - rlang          [* -> 1.1.7]
    - roxygen2       [* -> 7.3.3]
    - rprojroot      [* -> 2.1.1]
    - spelling       [* -> 2.3.2]
    - stringi        [* -> 1.8.7]
    - stringr        [* -> 1.6.0]
    - styler         [* -> 1.11.0]
    - V8             [* -> 8.0.1]
    - vctrs          [* -> 0.6.5]
    - withr          [* -> 3.0.2]
    - xfun           [* -> 0.55]
    - xml2           [* -> 1.5.1]
    - xmlparsedata   [* -> 1.0.5]
    - yaml           [* -> 2.3.12]
    
    # Downloading packages -------------------------------------------------------
    - Downloading Rcpp from RSPM ...                OK [file is up to date]
    - Downloading V8 from RSPM ...                  OK [file is up to date]
    - Downloading jsonlite from RSPM ...            OK [file is up to date]
    - Downloading curl from RSPM ...                OK [file is up to date]
    - Downloading backports from RSPM ...           OK [file is up to date]
    - Downloading brew from RSPM ...                OK [file is up to date]
    - Downloading callr from RSPM ...               OK [file is up to date]
    - Downloading processx from RSPM ...            OK [file is up to date]
    - Downloading ps from RSPM ...                  OK [file is up to date]
    - Downloading cli from RSPM ...                 OK [file is up to date]
    - Downloading commonmark from RSPM ...          OK [file is up to date]
    - Downloading cpp11 from RSPM ...               OK [file is up to date]
    - Downloading desc from RSPM ...                OK [file is up to date]
    - Downloading docopt from RSPM ...              OK [file is up to date]
    - Downloading evaluate from RSPM ...            OK [file is up to date]
    - Downloading fs from RSPM ...                  OK [file is up to date]
    - Downloading glue from RSPM ...                OK [file is up to date]
    - Downloading here from RSPM ...                OK [file is up to date]
    - Downloading rprojroot from RSPM ...           OK [file is up to date]
    - Downloading highr from RSPM ...               OK [file is up to date]
    - Downloading xfun from RSPM ...                OK [file is up to date]
    - Downloading hunspell from RSPM ...            OK [file is up to date]
    - Downloading jsonvalidate from RSPM ...        OK [file is up to date]
    - Downloading knitr from RSPM ...               OK [file is up to date]
    - Downloading yaml from RSPM ...                OK [file is up to date]
    - Downloading lazyeval from RSPM ...            OK [file is up to date]
    - Downloading lifecycle from RSPM ...           OK [file is up to date]
    - Downloading rlang from RSPM ...               OK [file is up to date]
    - Downloading lintr from RSPM ...               OK [file is up to date]
    - Downloading rex from RSPM ...                 OK [file is up to date]
    - Downloading xml2 from RSPM ...                OK [file is up to date]
    - Downloading xmlparsedata from RSPM ...        OK [file is up to date]
    - Downloading magrittr from RSPM ...            OK [file is up to date]
    - Downloading pkgbuild from RSPM ...            OK [file is up to date]
    - Downloading pkgload from RSPM ...             OK [file is up to date]
    - Downloading purrr from RSPM ...               OK [file is up to date]
    - Downloading vctrs from RSPM ...               OK [file is up to date]
    - Downloading roxygen2 from RSPM ...            OK [file is up to date]
    - Downloading stringi from RSPM ...             OK [file is up to date]
    - Downloading stringr from RSPM ...             OK [file is up to date]
    - Downloading withr from RSPM ...               OK [file is up to date]
    - Downloading spelling from RSPM ...            OK [file is up to date]
    - Downloading styler from RSPM ...              OK [file is up to date]
    Successfully downloaded 43 packages in 17 seconds.
    
    # Installing packages --------------------------------------------------------
    - Installing R.methodsS3 ...                    OK [linked from cache]
    - Installing R.oo ...                           OK [linked from cache]
    - Installing R.utils ...                        OK [linked from cache]
    - Installing digest ...                         OK [linked from cache]
    - Installing R.cache ...                        OK [linked from cache]
    - Installing R6 ...                             OK [linked from cache]
    - Installing Rcpp ...                           FAILED
    Traceback (most recent calls last):
    13: renv::restore()
    12: renv_restore_run_actions(project, diff, current, lockfile, rebuild)
    11: renv_install_impl(records)
    10: renv_install_staged(records)
     9: renv_install_default(records)
     8: handler(package, renv_install_package(record))
     7: renv_install_package(record)
     6: withCallingHandlers(renv_install_package_impl(record), error = function(e) writef("FAILED"))
     5: renv_install_package_impl(record)
     4: r_cmd_install(package, path)
     3: r_exec_error(package, output, "install", status)
     2: abort(all)
     1: stop(fallback)
stderr:
    Error: Error installing package 'Rcpp':
    ================================
    
    * installing *source* package ‘Rcpp’ ...
    ** this is package ‘Rcpp’ version ‘1.1.1’
    ** package ‘Rcpp’ successfully unpacked and MD5 sums checked
    ** using staged installation
    Warning: running 'cleanup' failed
    ** libs
    using C++ compiler: ‘Apple clang version 21.0.0 (clang-2100.0.123.102)’
    using SDK: ‘MacOSX26.4.1.sdk’
    clang++ -arch arm64 -std=gnu++20 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/  -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2   -c api.cpp -o api.o
    In file included from api.cpp:26:
    In file included from ../inst/include/Rcpp.h:49:
    ../inst/include/Rcpp/Function.h:75:65: error: use of undeclared identifier 'R_NamespaceRegistry'
       75 |             Shield<SEXP> env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_UnboundValue));
          |                                                                 ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    make: *** [api.o] Error 1
    ERROR: compilation failed for package ‘Rcpp’
    * removing ‘/Users/pschloss/.cache/pre-commit/reposinjmr3q/renv-default/renv/staging/1/Rcpp’
    install of package 'Rcpp' failed [error code 1]
    Execution halted
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pre-commit/4.6.0/libexec/lib/python3.14/site-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/opt/homebrew/Cellar/pre-commit/4.6.0/libexec/lib/python3.14/site-packages/pre_commit/main.py", line 401, in main
    return hook_impl(
        store,
    ...<5 lines>...
        args=args.rest[1:],
    )
  File "/opt/homebrew/Cellar/pre-commit/4.6.0/libexec/lib/python3.14/site-packages/pre_commit/commands/hook_impl.py", line 275, in hook_impl
    return retv | run(config, store, ns)
                  ~~~^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pre-commit/4.6.0/libexec/lib/python3.14/site-packages/pre_commit/commands/run.py", line 443, in run
    install_hook_envs(to_install, store)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pre-commit/4.6.0/libexec/lib/python3.14/site-packages/pre_commit/repository.py", line 229, in install_hook_envs
    _hook_install(hook)
    ~~~~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/pre-commit/4.6.0/libexec/lib/python3.14/site-packages/pre_commit/repository.py", line 85, in _hook_install
    lang.install_environment(
    ~~~~~~~~~~~~~~~~~~~~~~~~^
        hook.prefix, hook.language_version, hook.additional_dependencies,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/pre-commit/4.6.0/libexec/lib/python3.14/site-packages/pre_commit/languages/r.py", line 230, in install_environment
    _execute_vanilla_r(
    ~~~~~~~~~~~~~~~~~~^
        r_code_inst_environment,
        ^^^^^^^^^^^^^^^^^^^^^^^^
        prefix=prefix, version=version, cwd=env_dir,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/pre-commit/4.6.0/libexec/lib/python3.14/site-packages/pre_commit/languages/r.py", line 54, in _execute_vanilla_r
    return _execute_r(
        code=code, prefix=prefix, version=version, args=args, cwd=cwd,
        cli_opts=('--vanilla',),
    )
  File "/opt/homebrew/Cellar/pre-commit/4.6.0/libexec/lib/python3.14/site-packages/pre_commit/languages/r.py", line 34, in _execute_r
    _, out, _ = cmd_output(
                ~~~~~~~~~~^
        _rscript_exec(), *cli_opts, f, *args, cwd=cwd,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/pre-commit/4.6.0/libexec/lib/python3.14/site-packages/pre_commit/util.py", line 117, in cmd_output
    returncode, stdout_b, stderr_b = cmd_output_b(*cmd, **kwargs)
                                     ~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pre-commit/4.6.0/libexec/lib/python3.14/site-packages/pre_commit/util.py", line 111, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/Library/Frameworks/R.framework/Resources/bin/Rscript', '--vanilla', '/var/folders/ss/6msy9pqs3556370vh8s084l80000gp/T/tmpa0ef6b36/script.R')
return code: 1
stdout:
    # Bootstrapping renv 1.1.5 ---------------------------------------------------
    - Downloading renv ... OK
    - Installing renv  ... OK
    
    - One or more packages recorded in the lockfile are not installed.
    - Use `renv::status()` for more details.
    The following package(s) will be updated:
    
    # RSPM -----------------------------------------------------------------------
    - backports      [* -> 1.5.0]
    - brew           [* -> 1.0-10]
    - callr          [* -> 3.7.6]
    - cli            [* -> 3.6.5]
    - commonmark     [* -> 2.0.0]
    - cpp11          [* -> 0.5.2]
    - curl           [* -> 7.0.0]
    - desc           [* -> 1.4.3]
    - digest         [* -> 0.6.39]
    - docopt         [* -> 0.7.2]
    - evaluate       [* -> 1.0.5]
    - fs             [* -> 1.6.6]
    - glue           [* -> 1.8.0]
    - here           [* -> 1.0.2]
    - highr          [* -> 0.11]
    - hunspell       [* -> 3.0.6]
    - jsonlite       [* -> 2.0.0]
    - jsonvalidate   [* -> 1.5.0]
    - knitr          [* -> 1.51]
    - lazyeval       [* -> 0.2.2]
    - lifecycle      [* -> 1.0.5]
    - lintr          [* -> 3.3.0-1]
    - magrittr       [* -> 2.0.4]
    - pkgbuild       [* -> 1.4.8]
    - pkgload        [* -> 1.4.1]
    - processx       [* -> 3.8.6]
    - ps             [* -> 1.9.1]
    - purrr          [* -> 1.2.1]
    - R.cache        [* -> 0.17.0]
    - R.methodsS3    [* -> 1.8.2]
    - R.oo           [* -> 1.27.1]
    - R.utils        [* -> 2.13.0]
    - R6             [* -> 2.6.1]
    - Rcpp           [* -> 1.1.1]
    - rex            [* -> 1.2.1]
    - rlang          [* -> 1.1.7]
    - roxygen2       [* -> 7.3.3]
    - rprojroot      [* -> 2.1.1]
    - spelling       [* -> 2.3.2]
    - stringi        [* -> 1.8.7]
    - stringr        [* -> 1.6.0]
    - styler         [* -> 1.11.0]
    - V8             [* -> 8.0.1]
    - vctrs          [* -> 0.6.5]
    - withr          [* -> 3.0.2]
    - xfun           [* -> 0.55]
    - xml2           [* -> 1.5.1]
    - xmlparsedata   [* -> 1.0.5]
    - yaml           [* -> 2.3.12]
    
    # Downloading packages -------------------------------------------------------
    - Downloading Rcpp from RSPM ...                OK [file is up to date]
    - Downloading V8 from RSPM ...                  OK [file is up to date]
    - Downloading jsonlite from RSPM ...            OK [file is up to date]
    - Downloading curl from RSPM ...                OK [file is up to date]
    - Downloading backports from RSPM ...           OK [file is up to date]
    - Downloading brew from RSPM ...                OK [file is up to date]
    - Downloading callr from RSPM ...               OK [file is up to date]
    - Downloading processx from RSPM ...            OK [file is up to date]
    - Downloading ps from RSPM ...                  OK [file is up to date]
    - Downloading cli from RSPM ...                 OK [file is up to date]
    - Downloading commonmark from RSPM ...          OK [file is up to date]
    - Downloading cpp11 from RSPM ...               OK [file is up to date]
    - Downloading desc from RSPM ...                OK [file is up to date]
    - Downloading docopt from RSPM ...              OK [file is up to date]
    - Downloading evaluate from RSPM ...            OK [file is up to date]
    - Downloading fs from RSPM ...                  OK [file is up to date]
    - Downloading glue from RSPM ...                OK [file is up to date]
    - Downloading here from RSPM ...                OK [file is up to date]
    - Downloading rprojroot from RSPM ...           OK [file is up to date]
    - Downloading highr from RSPM ...               OK [file is up to date]
    - Downloading xfun from RSPM ...                OK [file is up to date]
    - Downloading hunspell from RSPM ...            OK [file is up to date]
    - Downloading jsonvalidate from RSPM ...        OK [file is up to date]
    - Downloading knitr from RSPM ...               OK [file is up to date]
    - Downloading yaml from RSPM ...                OK [file is up to date]
    - Downloading lazyeval from RSPM ...            OK [file is up to date]
    - Downloading lifecycle from RSPM ...           OK [file is up to date]
    - Downloading rlang from RSPM ...               OK [file is up to date]
    - Downloading lintr from RSPM ...               OK [file is up to date]
    - Downloading rex from RSPM ...                 OK [file is up to date]
    - Downloading xml2 from RSPM ...                OK [file is up to date]
    - Downloading xmlparsedata from RSPM ...        OK [file is up to date]
    - Downloading magrittr from RSPM ...            OK [file is up to date]
    - Downloading pkgbuild from RSPM ...            OK [file is up to date]
    - Downloading pkgload from RSPM ...             OK [file is up to date]
    - Downloading purrr from RSPM ...               OK [file is up to date]
    - Downloading vctrs from RSPM ...               OK [file is up to date]
    - Downloading roxygen2 from RSPM ...            OK [file is up to date]
    - Downloading stringi from RSPM ...             OK [file is up to date]
    - Downloading stringr from RSPM ...             OK [file is up to date]
    - Downloading withr from RSPM ...               OK [file is up to date]
    - Downloading spelling from RSPM ...            OK [file is up to date]
    - Downloading styler from RSPM ...              OK [file is up to date]
    Successfully downloaded 43 packages in 17 seconds.
    
    # Installing packages --------------------------------------------------------
    - Installing R.methodsS3 ...                    OK [linked from cache]
    - Installing R.oo ...                           OK [linked from cache]
    - Installing R.utils ...                        OK [linked from cache]
    - Installing digest ...                         OK [linked from cache]
    - Installing R.cache ...                        OK [linked from cache]
    - Installing R6 ...                             OK [linked from cache]
    - Installing Rcpp ...                           FAILED
    Traceback (most recent calls last):
    13: renv::restore()
    12: renv_restore_run_actions(project, diff, current, lockfile, rebuild)
    11: renv_install_impl(records)
    10: renv_install_staged(records)
     9: renv_install_default(records)
     8: handler(package, renv_install_package(record))
     7: renv_install_package(record)
     6: withCallingHandlers(renv_install_package_impl(record), error = function(e) writef("FAILED"))
     5: renv_install_package_impl(record)
     4: r_cmd_install(package, path)
     3: r_exec_error(package, output, "install", status)
     2: abort(all)
     1: stop(fallback)
stderr:
    Error: Error installing package 'Rcpp':
    ================================
    
    * installing *source* package ‘Rcpp’ ...
    ** this is package ‘Rcpp’ version ‘1.1.1’
    ** package ‘Rcpp’ successfully unpacked and MD5 sums checked
    ** using staged installation
    Warning: running 'cleanup' failed
    ** libs
    using C++ compiler: ‘Apple clang version 21.0.0 (clang-2100.0.123.102)’
    using SDK: ‘MacOSX26.4.1.sdk’
    clang++ -arch arm64 -std=gnu++20 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/  -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2   -c api.cpp -o api.o
    In file included from api.cpp:26:
    In file included from ../inst/include/Rcpp.h:49:
    ../inst/include/Rcpp/Function.h:75:65: error: use of undeclared identifier 'R_NamespaceRegistry'
       75 |             Shield<SEXP> env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_UnboundValue));
          |                                                                 ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    make: *** [api.o] Error 1
    ERROR: compilation failed for package ‘Rcpp’
    * removing ‘/Users/pschloss/.cache/pre-commit/reposinjmr3q/renv-default/renv/staging/1/Rcpp’
    install of package 'Rcpp' failed [error code 1]
    Execution halted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions