fix(impl-generate): suppress renv stdout in R version probe#6948
Merged
Conversation
renv prints its "project out-of-sync" notice on stdout from .Rprofile, so 2>/dev/null leaves it inside the captured value. The polluted multi-line string then breaks the downstream Python heredoc with an unterminated string literal, and a backtick in the notice splits the bash command so --model lands as a standalone token. Setting RENV_CONFIG_STARTUP_QUIET=TRUE silences renv at startup; piping through tail -n1 keeps a single clean version line as a fallback. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the implementation generation workflow’s R version probes so renv startup output does not pollute generated metadata or break downstream shell/Python interpolation.
Changes:
- Suppresses renv startup notices during R version probes with
RENV_CONFIG_STARTUP_QUIET=TRUE. - Pipes R runtime and package version probe output through
tail -n1. - Adds a fallback to
unknownfor empty R language version output.
| } | ||
| get_r_version() { | ||
| Rscript -e "cat(as.character(packageVersion('$1')))" 2>/dev/null | ||
| RENV_CONFIG_STARTUP_QUIET=TRUE Rscript -e "cat(as.character(packageVersion('$1')))" 2>/dev/null | tail -n1 |
Apply Copilot review feedback on #6948: if Rscript exits non-zero after partial stdout, `tail -n1` would still return that leaked line as LIBRARY_VERSION, defeating the renv-quiet protection. Add an is_version() regex (`^[0-9]+(\.[0-9]+)*$`) and reject anything that doesn't match — empty result falls through to the existing "unknown" fallback. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
renv's"- The project is out-of-sync -- use \renv::status()` for details."notice prints on **stdout** from.Rprofile, so2>/dev/nullleft it insideLANGUAGE_VERSION/LIBRARY_VERSION`.SyntaxError: unterminated string literal), and a backtick in the notice split the bash command so--modelended up as a standalone token (--model: command not found).Rscriptprobes withRENV_CONFIG_STARTUP_QUIET=TRUEand pipe throughtail -n1as a belt-and-suspenders against future stdout leaks. BothgetRversion()andpackageVersion()emit a single line, so trailing-line slicing is safe.Context
Observed in run 25972681609 (bulk-generate ggplot2 for scatter-basic), which dispatched 2+ failing impl-generate runs with identical traces:
The underlying renv.lock-vs-installed-packages drift that triggers the notice is a separate concern; this PR just stops the version probe from being a footgun.
Test plan
bulk-generate.yml -f specification_id=scatter-basic -f library=ggplot2and confirm impl-generate's version-probe step logs e.g.Library version: ggplot2 = 3.5.1 (r runtime 4.4.1, pipeline python 3.13.13)without renv noiseplots/scatter-basic/metadata/r/ggplot2.yamlwith populatedlanguage_version,quality_score, and a reachable GCS preview image🤖 Generated with Claude Code