Any way to reuse/cache package builds?

I've got a Shiny app which uses a few map/geography packages and which I deploy to posit connect. These packages take over 20 minutes to install/build on every deployment (and the builds also happen on every setting change).

Is there any suggestion for how to improve this deploy/build time? I'm already specifying https://packagemanager.rstudio.com/all/latest as the CRAN repo in my renv.lock, but this doesn't seem to help in this situation.

Hi @slodge, could you clarify whether you're deploying to Connect or Connect Cloud?

This project is on the public posit connect cloud deploying from positron using the publisher extension.

Hi @slodge
Package caching and reuse like you describe has been an area of intense focus in Connect Cloud's engineering, and in general I wouldn't expect packages available on public CRAN to require full builds on every publish like you describe.

Has this issue been ongoing for you? Connect Cloud's primary package caching/reuse strategy involves a central shared package cache that is added to based on packages we see people using. I see for example that a package called "earth" got successfully added to this central cache yesterday.

If this is ongoing, please share the package names affected; I'd be interested in investigating.

Thanks
Mike

1 Like

Thanks.

I just tried a republish and it's definitely still building packages.

Some of my packages are marked as RSPM in my renv.lock - could that be the source of the problem?

The content is GUID 019ae407-8b40-eb69-6049-aa3bf55054b6 with publish request 6215bb10-4f93-4f93-9455-28511a054da1 - an example package being rebuilt is cli version 3.6.5:

renv.lock entry:

    "cli": {
      "Package": "cli",
      "Version": "3.6.5",
      "Source": "Repository",
      "Title": "Helpers for Developing Command Line Interfaces",
      "Authors@R": "c( person(\"Gábor\", \"Csárdi\", , \"gabor@posit.co\", role = c(\"aut\", \"cre\")), person(\"Hadley\", \"Wickham\", role = \"ctb\"), person(\"Kirill\", \"Müller\", role = \"ctb\"), person(\"Salim\", \"Brüggemann\", , \"salim-b@pm.me\", role = \"ctb\", comment = c(ORCID = \"0000-0002-5329-5987\")), person(\"Posit Software, PBC\", role = c(\"cph\", \"fnd\")) )",
      "Description": "A suite of tools to build attractive command line interfaces ('CLIs'), from semantic elements: headings, lists, alerts, paragraphs, etc. Supports custom themes via a 'CSS'-like language. It also contains a number of lower level 'CLI' elements: rules, boxes, trees, and 'Unicode' symbols with 'ASCII' alternatives. It support ANSI colors and text styles as well.",
      "License": "MIT + file LICENSE",
      "URL": "https://cli.r-lib.org, https://github.com/r-lib/cli",
      "BugReports": "https://github.com/r-lib/cli/issues",
      "Depends": [
        "R (>= 3.4)"
      ],
      "Imports": [
        "utils"
      ],
      "Suggests": [
        "callr",
        "covr",
        "crayon",
        "digest",
        "glue (>= 1.6.0)",
        "grDevices",
        "htmltools",
        "htmlwidgets",
        "knitr",
        "methods",
        "processx",
        "ps (>= 1.3.4.9000)",
        "rlang (>= 1.0.2.9003)",
        "rmarkdown",
        "rprojroot",
        "rstudioapi",
        "testthat (>= 3.2.0)",
        "tibble",
        "whoami",
        "withr"
      ],
      "Config/Needs/website": "r-lib/asciicast, bench, brio, cpp11, decor, desc, fansi, prettyunits, sessioninfo, tidyverse/tidytemplate, usethis, vctrs",
      "Config/testthat/edition": "3",
      "Encoding": "UTF-8",
      "RoxygenNote": "7.3.2",
      "NeedsCompilation": "yes",
      "Author": "Gábor Csárdi [aut, cre], Hadley Wickham [ctb], Kirill Müller [ctb], Salim Brüggemann [ctb] (<https://orcid.org/0000-0002-5329-5987>), Posit Software, PBC [cph, fnd]",
      "Maintainer": "Gábor Csárdi <gabor@posit.co>",
      "Repository": "RSPM"
    },

Some publish logs...

2026-02-02T12:24:59+00:00 * installing *source* package ‘cli’ ...
2026-02-02T12:24:59+00:00 ** this is package ‘cli’ version ‘3.6.5’
2026-02-02T12:24:59+00:00 ** package ‘cli’ successfully unpacked and MD5 sums checked
2026-02-02T12:24:59+00:00 ** using staged installation
2026-02-02T12:24:59+00:00 ** libs
2026-02-02T12:24:59+00:00 ** help
2026-02-02T12:24:59+00:00 using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0’
2026-02-02T12:24:59+00:00 gcc -I"/opt/R/4.5.1/lib/R/include" -DNDEBUG -I../inst/include  -I/usr/local/include   -fvisibility=hidden -fpic  -g -O2  -c ansi.c -o ansi.o
2026-02-02T12:24:59+00:00 gcc -I"/opt/R/4.5.1/lib/R/include" -DNDEBUG -I../inst/include  -I/usr/local/include   -fvisibility=hidden -fpic  -g -O2  -c cleancall.c -o cleancall.o
202

Hi @slodge
Thanks for the additional information. The short answer is yes, because this package was installed from RSPM, Connect Cloud isn't confident that it can use its cached version. (Some specifics of how the Positron publisher extension is communicating the package information to Connect Cloud is also involved.)

Your easiest immediate practical fix might be to reinstall those packages locally from CRAN. It's also likely that if you removed the publisher extension from the equation and published via GitHub instead, that it would also work.

Thanks for calling this to our attention, we'll work to make RSPM packages sent via the publisher extension more likely to be cached.

Mike

1 Like

Thanks...

Funnily enough, CRAN in our case is RSPM :slight_smile:

  "R": {
    "Version": "4.5.1",
    "Repositories": [
      {
        "Name": "CRAN",
        "URL": "https://packagemanager.rstudio.com/all/latest"
      }
    ]
  },

... so I just did a search and replace RSPM to CRAN in our renv.lock file...

Publishing now takes a few seconds :+1: - thanks!

1 Like