{"record":{"id":"bd4bf110a5c38eb2","repo":"ruby/rubygems","slug":"the-ruby-version-locked-ruby-version-from-l","errorCode":null,"errorMessage":"The Ruby version #{@locked_ruby_version} from #{@lockfile} could not be parsed. Try running bundle update --ruby to resolve this.","messagePattern":"The Ruby version #(.+?) from #(.+?) could not be parsed\\. Try running bundle update --ruby to resolve this\\.","errorType":"exception","errorClass":"LockfileError","httpStatus":null,"severity":"error","filePath":"lib/bundler/definition.rb","lineNumber":464,"sourceCode":"      rescue ReadOnlyFileSystemError\n        raise ProductionError, lockfile_changes_summary(\"file system is read-only\")\n      end\n    end\n\n    def locked_ruby_version\n      return unless ruby_version\n      if @unlocking_ruby || !@locked_ruby_version\n        Bundler::RubyVersion.system\n      else\n        @locked_ruby_version\n      end\n    end\n\n    def locked_ruby_version_object\n      return unless @locked_ruby_version\n      @locked_ruby_version_object ||= begin\n        unless version = RubyVersion.from_string(@locked_ruby_version)\n          raise LockfileError, \"The Ruby version #{@locked_ruby_version} from \" \\\n            \"#{@lockfile} could not be parsed. \" \\\n            \"Try running bundle update --ruby to resolve this.\"\n        end\n        version\n      end\n    end\n\n    def bundler_version_to_lock\n      @resolved_bundler_version || Bundler.gem_version\n    end\n\n    def to_lock\n      require_relative \"lockfile_generator\"\n      LockfileGenerator.generate(self)\n    end\n\n    def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)\n      return unless Bundler.frozen_bundle?","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/bundler/definition.rb#L446-L482","documentation":"Definition#locked_ruby_version_object parses the RUBY VERSION entry recorded in Gemfile.lock (@locked_ruby_version) with RubyVersion.from_string; when the recorded string does not match a recognized ruby/engine version format it raises Bundler::LockfileError advising `bundle update --ruby` (lib/bundler/definition.rb:464). The lockfile itself carries an uninterpretable Ruby version line: hand-edited, mangled by a merge, or written by tooling with a different format expectation.","triggerScenarios":"A Gemfile.lock whose RUBY VERSION block was edited badly or truncated; git merge conflicts resolved by hand around the RUBY VERSION section; lockfiles generated by string-concatenating scripts or by much older bundler versions; control characters or broken line endings corrupting the version line.","commonSituations":"Merge conflicts in Gemfile.lock resolved as raw text instead of re-locking; scripts that rewrite lockfiles without bundler; version jumps between very old and new bundler; CRLF conversions corrupting the section.","solutions":["Run `bundle update --ruby` as the message suggests to re-lock the ruby directive cleanly","Open Gemfile.lock and fix or delete the malformed RUBY VERSION block, then run `bundle install`","Check the Gemfile `ruby` directive itself for an invalid version string and correct it before re-locking","Last resort: delete Gemfile.lock and run `bundle install` to regenerate it, accepting a full re-resolution"],"exampleFix":"# before (Gemfile.lock)\nRUBY VERSION\n   ruby 3.2.\n\n# after\nRUBY VERSION\n   ruby 3.2.2","handlingStrategy":"validation","validationCode":"require \"bundler/ruby_version\"\nlock = Bundler.default_lockfile.read\nline = lock[/^RUBY VERSION\\n\\s+(\\S.*)$/, 1]\nif line && !Bundler::RubyVersion.from_string(line.strip)\n  abort \"unparsable RUBY VERSION in Gemfile.lock; run bundle update --ruby\"\nend","typeGuard":null,"tryCatchPattern":"begin\n  Bundler.definition.locked_ruby_version_object\nrescue Bundler::LockfileError => e\n  system(\"bundle\", \"update\", \"--ruby\") || abort(e.message)\nend","preventionTips":["Never hand-edit RUBY VERSION blocks; re-lock instead","Resolve Gemfile.lock conflicts by regenerating, not by merging text","Prevent CRLF mangles in lockfiles via .gitattributes or editor config"],"tags":["bundler","lockfile","ruby-version","parse-error","merge-conflict"],"backgroundTag":"lockfile-parse-error","analyzedSha":"86cbb817a38ce8477b181c17467a703ded3f2be8","analyzedAt":"2026-08-23T06:27:48.159Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}