{"record":{"id":"e9b8fa8a7896de8e","repo":"jdx/mise","slug":"ruby-build-version-regex","errorCode":null,"errorMessage":"ruby-build version regex","messagePattern":"ruby-build version regex","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/plugins/core/ruby.rs","lineNumber":275,"sourceCode":"                .with_pr(pr)\n                .arg(\"install\")\n                .envs(config.env().await?)\n                .env_values(tv.install_env());\n            match package.split_once(' ') {\n                Some((name, \"--pre\")) => cmd = cmd.arg(name).arg(\"--pre\"),\n                Some((name, version)) => cmd = cmd.arg(name).arg(\"--version\").arg(version),\n                None => cmd = cmd.arg(package),\n            };\n            cmd.env(&*PATH_KEY, plugins::core::path_env_with_tv_path(tv)?)\n                .execute()?;\n        }\n        Ok(())\n    }\n\n    fn ruby_build_version(&self) -> Result<String> {\n        let output = cmd!(self.ruby_build_bin(), \"--version\").read()?;\n        let re = regex!(r\"^ruby-build ([0-9.]+)\");\n        let caps = re.captures(&output).expect(\"ruby-build version regex\");\n        Ok(caps.get(1).unwrap().as_str().to_string())\n    }\n\n    async fn latest_ruby_build_version(&self) -> Result<String> {\n        let release: GithubRelease = HTTP_FETCH\n            .json(\"https://api.github.com/repos/rbenv/ruby-build/releases/latest\")\n            .await?;\n        Ok(release.tag_name.trim_start_matches('v').to_string())\n    }\n\n    fn install_rubygems_hook(&self, tv: &ToolVersion) -> Result<()> {\n        let site_ruby_path = tv.install_path().join(\"lib/ruby/site_ruby\");\n        let f = site_ruby_path.join(\"rubygems_plugin.rb\");\n        file::create_dir_all(site_ruby_path)?;\n        file::write(f, include_str!(\"assets/rubygems_plugin.rb\"))?;\n        Ok(())\n    }\n","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/plugins/core/ruby.rs#L257-L293","documentation":"mise panics with 'ruby-build version regex' in `ruby_build_version` when the output of `ruby-build --version` does not match `^ruby-build ([0-9.]+)`. The regex expects the first line to start with 'ruby-build ' followed by a dotted numeric version; any other output (localization, warnings, prefix text, or a changed upstream format) leaves `captures` as `None` and the expect panics.","triggerScenarios":"Running a ruby-build whose `--version` output changed format (new rbenv/ruby-build release), a shim/wrapper that prints extra text before the version line, stderr warnings interleaved into captured output, or a custom `ruby-build` binary (MISE_RUBY_BUILD_PATH or PATH shadowing) that is not the real ruby-build.","commonSituations":"Users with an old, forked, or Homebrew-patched ruby-build; rbenv's ruby-build printing deprecation notices; network/venv hooks emitting banners into the command output; environments where `ruby-build` resolves to a different tool with the same name.","solutions":["Update ruby-build to the latest release (`git -C ~/.rbenv/plugins/ruby-build pull` or package manager upgrade)","Run `ruby-build --version` manually and check the output matches 'ruby-build <numbers>'","Ensure the resolved `ruby_build_bin()` is the real ruby-build, not a shim or different tool shadowing it on PATH","Make the code return a descriptive error on regex mismatch instead of panicking"],"exampleFix":"// before\nlet caps = re.captures(&output).expect(\"ruby-build version regex\");\nOk(caps.get(1).unwrap().as_str().to_string())\n// after\nlet caps = re.captures(&output)\n    .with_context(|| format!(\"unexpected ruby-build version output: {output}\"))?;\nOk(caps.get(1).unwrap().as_str().to_string())","handlingStrategy":"validation","validationCode":"let output = cmd!(bin, \"--version\").read()?; if !output.starts_with(\"ruby-build \") { bail!(\"unexpected ruby-build output: {output}\"); }","typeGuard":"fn is_ruby_build_version_output(s: &str) -> bool { s.starts_with(\"ruby-build \") }","tryCatchPattern":"let Some(caps) = re.captures(&output) else { bail!(\"unexpected ruby-build --version output: {output}\") };","preventionTips":["Keep ruby-build updated to current rbenv releases","Run `ruby-build --version` manually to verify output format when upgrades fail","Ensure no shim or unrelated binary shadows ruby-build on PATH","Treat version-parsing mismatches as errors, not panics"],"tags":["rust","ruby","regex","version-detection","panic"],"backgroundTag":"unexpected-response-shape","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}