Skip to content

support for parsing renv.lock#785

Open
amol- wants to merge 4 commits into
mainfrom
issue-784
Open

support for parsing renv.lock#785
amol- wants to merge 4 commits into
mainfrom
issue-784

Conversation

@amol-

@amol- amol- commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Intent

Closes #784

Type of Change

  • Bug Fix
  • New Feature
  • Breaking Change

Approach

Implement a r_environment that detects renv.lock and parses the dependencies.

Automated Tests

Directions for Reviewers

Checklist

  • I have updated CHANGELOG.md to cover notable changes.
  • I have updated all related GitHub issues to reflect their current state.
  • I have run the rsconnect-python-tests-at-night workflow in Connect against this feature branch.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://posit-dev.github.io/rsconnect-python/pr-preview/pr-785/

Built to branch gh-pages at 2026-06-18 08:50 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
7203 5878 82% 0% 🟢

New Files

File Coverage Status
rsconnect/environment_r.py 93% 🟢
TOTAL 93% 🟢

Modified Files

File Coverage Status
rsconnect/actions.py 58% 🟢
rsconnect/bundle.py 85% 🟢
rsconnect/main.py 80% 🟢
TOTAL 74% 🟢

updated for commit: 27febf4 by action🐍

@amol- amol- requested a review from jonkeane June 17, 2026 14:32
@amol- amol- marked this pull request as ready for review June 17, 2026 14:32
@jonkeane jonkeane requested a review from karawoo June 17, 2026 14:38

@karawoo karawoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me and I was able to generate several correct manifests with it. A couple of minor questions below.

As far as I understand we don't expect this to actually work on Connect just yet, and indeed I was not able to deploy my content (quarto project using jupyter engine) to Connect. But the manifest itself looked fine, so I don't think it's an issue with anything here.

Comment on lines +5 to +7
The parse is pure: it reads only renv.lock and never invokes R or inspects
locally installed R packages. This mirrors how Posit Publisher resolves R
dependencies for Python content that also uses R (e.g. rpy2 apps).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that lockfiles outside of the project root will not be respected, correct? Lockfiles can legitimately be in other locations, either through setting RENV_PATHS_LOCKFILE or if the user is using renv profiles.

In the rsconnect R package this is supported (rstudio/rsconnect#1296). If we are choosing not to support it here, or not for now (which I think is a reasonable choice) then could we document that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did mimic the code in publisher, but I realised now that publisher does invoke the R interpreter thus it would probably handle the profiles and the RENV_PATHS_LOCKFILE by virtue of that.

Invoking the R interpreter didn't seem a good idea in rsconnect-python because I don't want to force the need to install an R environment just to deploy a python project.

As a trade-off I support for RENV_PATHS_LOCKFILE as it was easy enough to support and documented the behavior. I think that in the majority of rpy2 projects it will be perfectly fine to support the renv.lock exclusively in the project directory as it will be shipped with the project itself, but RENV_PATHS_LOCKFILE is a solid escape hatch for exceptions

d4717af

Comment thread rsconnect/actions.py
@amol-

amol- commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

As far as I understand we don't expect this to actually work on Connect just yet, and indeed I was not able to deploy my content (quarto project using jupyter engine) to Connect. But the manifest itself looked fine, so I don't think it's an issue with anything here.

Correct, that is undergoing work in connect side

Comment on lines +97 to +100
# "a directory" so renv.lock is appended. A relative override resolves against
# the current working directory (matching renv), not the project directory.
# With no override we fall back to renv's default of <project>/renv.lock.
override = os.environ.get("RENV_PATHS_LOCKFILE")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment isn't correct about renv's behavior as of the most recent renv version: it resolves against the project directory, not the working directory.

https://github.com/rstudio/renv/blob/538c71944aab9b02d78ddaab626e70713ffcc1f4/R/paths.R#L66-L70

(introduced in rstudio/renv@f0ab135)

Could we adjust the behavior to match and add a test for relative paths in RENV_PATHS_LOCKFILE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rsconnect-python support for generating R dependencies in manifest via renv.lock

2 participants