Repository navigation
fix(ruby): read the runtime from ruby file: and version files - #644
Merged
Merged
Conversation
Bundler 2.4 `ruby file:` and a Gemfile with no ruby line left `vg scan` with no Ruby runtime, so runtime lag was skipped. Read the named version file, then `.ruby-version` and a `ruby` entry in `.tool-versions`. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: vibgrate-team <vibgrate-team@users.noreply.github.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.
Closes #625
Summary
vg scanreported no Ruby runtime, and therefore no runtime lag, when a Gemfile used Bundler 2.4+'sruby file: ".ruby-version"form, or had norubyline and the project pinned Ruby in.ruby-versionor.tool-versions.The cause is
extractRubyVersionin the Ruby scanner. It only matched a quoted version on therubyline (ruby '3.3.0'/ruby ">= 3.1"). Afile:directive never matched, and nothing read.ruby-versionor.tool-versions, so the project was stored with no runtime.Fix
ruby file: "<path>",ruby file: '<path>', andruby :file => "<path>"are read from that path, resolved relative to the Gemfile. Reads go through the scan's existing file cache (or the samereadTextFile/pathExistshelpers when no cache is in use). A missing or unreadable file does not fail the project and does not fall through to another pin.rubyline, the scanner falls back to.ruby-versionnext to the Gemfile, then arubyentry in.tool-versions.ruby-prefix, soruby-3.2.2is3.2.2. A non-version token such assystemis skipped.ruby '3.1.0'(orruby ">= 3.1") line still wins over those files.Tests
test/ruby-runtime-pin.test.tscovers the parser and a fullscanRubyProjectspass, with and withoutFileCache:ruby file: ".ruby-version"with3.3.4in that file reports runtime3.3.4and a runtime lag.rubyline and.ruby-versionofruby-3.2.2reports3.2.2(ahead of a different.tool-versionsentry).ruby '3.1.0'line reports3.1.0even when both pin files name other versions.:file =>hash rocket, a path relative to the Gemfile, and the.tool-versionsfallback.ruby file:target does not throw.pnpm test,pnpm lint, andpnpm typecheckpass.Checklist
pnpm testpassespnpm lintis cleanpnpm typecheckis cleangraph.json/ report output (content-hashed IDs, stable sorts; no time, randomness, or filesystem-order dependence)git commit -s, DCO)