Skip to content

fix(ruby): read the runtime from ruby file: and version files - #644

Merged
vibgrate-team merged 1 commit into
mainfrom
cursor/ruby-version-file-pin-04fc
Nov 11, 2026
Merged

vibgrate-team merged 1 commit into
mainfrom
cursor/ruby-version-file-pin-04fc

Conversation

@vibgrate-team

Copy link
Copy Markdown
Contributor

Closes #625

Summary

vg scan reported no Ruby runtime, and therefore no runtime lag, when a Gemfile used Bundler 2.4+'s ruby file: ".ruby-version" form, or had no ruby line and the project pinned Ruby in .ruby-version or .tool-versions.

The cause is extractRubyVersion in the Ruby scanner. It only matched a quoted version on the ruby line (ruby '3.3.0' / ruby ">= 3.1"). A file: directive never matched, and nothing read .ruby-version or .tool-versions, so the project was stored with no runtime.

Fix

  • ruby file: "<path>", ruby file: '<path>', and ruby :file => "<path>" are read from that path, resolved relative to the Gemfile. Reads go through the scan's existing file cache (or the same readTextFile / pathExists helpers when no cache is in use). A missing or unreadable file does not fail the project and does not fall through to another pin.
  • When the Gemfile has no ruby line, the scanner falls back to .ruby-version next to the Gemfile, then a ruby entry in .tool-versions.
  • File contents lose surrounding whitespace and a leading ruby- prefix, so ruby-3.2.2 is 3.2.2. A non-version token such as system is skipped.
  • An explicit ruby '3.1.0' (or ruby ">= 3.1") line still wins over those files.

Tests

test/ruby-runtime-pin.test.ts covers the parser and a full scanRubyProjects pass, with and without FileCache:

  • ruby file: ".ruby-version" with 3.3.4 in that file reports runtime 3.3.4 and a runtime lag.
  • A Gemfile with no ruby line and .ruby-version of ruby-3.2.2 reports 3.2.2 (ahead of a different .tool-versions entry).
  • An explicit ruby '3.1.0' line reports 3.1.0 even when both pin files name other versions.
  • Single quotes, the :file => hash rocket, a path relative to the Gemfile, and the .tool-versions fallback.
  • A missing ruby file: target does not throw.

pnpm test, pnpm lint, and pnpm typecheck pass.

Checklist

  • pnpm test passes
  • pnpm lint is clean
  • pnpm typecheck is clean
  • Docs updated (README / DOCS / ARCHITECTURE) where behavior changed — none of those describe how the Ruby runtime is chosen
  • Determinism preserved — identical input still produces identical graph.json / report output (content-hashed IDs, stable sorts; no time, randomness, or filesystem-order dependence)
  • No proprietary or internal references — public, Apache-2.0 content only
  • Commits use Conventional Commits and are signed off (git commit -s, DCO)
Open in Web Open in Cursor 

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>
@vibgrate-team
vibgrate-team merged commit 357a5a2 into main Nov 11, 2026
1 check passed
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.

Enhancement: read the Ruby version from ruby file: ".ruby-version" and .ruby-version

2 participants