Skip to content

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

Closed

Description

@vibgrate-team

Context

extractRubyVersion in src/core-open/scanners/ruby-scanner.ts only understands ruby '3.3.0' in the Gemfile. Bundler 2.4+ projects often write ruby file: ".ruby-version", and many apps have no ruby line at all and rely on .ruby-version (or .tool-versions). In both cases vg scan reports no Ruby runtime and no runtime lag.

What to do

  • Support ruby file: "<path>" (and ruby file: '<path>') by reading that file relative to the Gemfile.
  • When the Gemfile has no ruby line, fall back to .ruby-version next to it, then a ruby entry in .tool-versions.
  • Strip a leading ruby- prefix (ruby-3.3.0) as rbenv/rvm write it.
  • Add unit tests.

Acceptance

  • ruby file: ".ruby-version" with 3.3.4 in that file reports runtime 3.3.4.
  • A Gemfile with no ruby line and a .ruby-version of ruby-3.2.2 reports 3.2.2.
  • An explicit ruby '3.1.0' line still wins over the files.

Activity

  1. added
    enhancement
    on Nov 10, 2026
  2. vibgrate-team commented on Nov 10, 2026

    @vibgrate-team
    ContributorAuthor

    Confirmed: extractRubyVersion (line 392 of src/core-open/scanners/ruby-scanner.ts) only matches literal ruby '...' lines, so ruby file: ".ruby-version" and Gemfiles without a ruby line give no runtime.

    Order of precedence I'd suggest: an explicit ruby 'x.y.z', then ruby file: resolved relative to the Gemfile, then .ruby-version beside it, then the ruby line of .tool-versions. Strip a ruby- prefix and trim whitespace. Since the scanner already reads files through the cache around line 484, keep the new reads there so extractRubyVersion stays a pure parser that is easy to unit-test.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions