From 8e610285fe00033ffa9333f03058f5b660607fbc Mon Sep 17 00:00:00 2001 From: Alex Rocha Date: Mon, 9 Mar 2026 13:54:54 -0700 Subject: [PATCH] Suppress version manager environment errors from extension telemetry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To avoid telemetry noise from user environment issues we convert all version manager throw sites to NonReportableError. These are cases where the tool is missing, misconfigured, or the workspace lacks expected files — none of which indicate Ruby LSP bugs. Covers: shadowenv, chruby, mise, rbenv, rvm, asdf, custom, and rv. --- vscode/src/ruby/asdf.ts | 6 ++++-- vscode/src/ruby/chruby.ts | 14 ++++++++++---- vscode/src/ruby/custom.ts | 4 ++-- vscode/src/ruby/mise.ts | 8 +++++--- vscode/src/ruby/rbenv.ts | 6 ++++-- vscode/src/ruby/rv.ts | 4 ++-- vscode/src/ruby/rvm.ts | 4 ++-- vscode/src/ruby/shadowenv.ts | 6 +++--- 8 files changed, 32 insertions(+), 20 deletions(-) diff --git a/vscode/src/ruby/asdf.ts b/vscode/src/ruby/asdf.ts index e06ff5a34b..0a846d41e2 100644 --- a/vscode/src/ruby/asdf.ts +++ b/vscode/src/ruby/asdf.ts @@ -3,7 +3,7 @@ import path from "path"; import * as vscode from "vscode"; -import { VersionManager, ActivationResult } from "./versionManager"; +import { VersionManager, ActivationResult, NonReportableError } from "./versionManager"; // A tool to manage multiple runtime versions with a single CLI tool // @@ -82,7 +82,9 @@ export class Asdf extends VersionManager { this.outputChannel.info(`Using configured ASDF executable path: ${asdfPath}`); return configuredPath.fsPath; } catch (_error: any) { - throw new Error(`ASDF executable configured as ${configuredPath.fsPath}, but that file doesn't exist`); + throw new NonReportableError( + `ASDF executable configured as ${configuredPath.fsPath}, but that file doesn't exist`, + ); } } } diff --git a/vscode/src/ruby/chruby.ts b/vscode/src/ruby/chruby.ts index efc33ce86f..9c067f7e45 100644 --- a/vscode/src/ruby/chruby.ts +++ b/vscode/src/ruby/chruby.ts @@ -5,7 +5,13 @@ import * as vscode from "vscode"; import { WorkspaceChannel } from "../workspaceChannel"; -import { ActivationResult, MissingRubyError, VersionManager, ACTIVATION_SEPARATOR } from "./versionManager"; +import { + ActivationResult, + MissingRubyError, + NonReportableError, + VersionManager, + ACTIVATION_SEPARATOR, +} from "./versionManager"; interface RubyVersion { engine?: string; @@ -248,13 +254,13 @@ export class Chruby extends VersionManager { } if (version === "") { - throw new Error(`Ruby version file ${rubyVersionUri.fsPath} is empty`); + throw new NonReportableError(`Ruby version file ${rubyVersionUri.fsPath} is empty`); } const match = /((?[A-Za-z]+)-)?(?\d+\.\d+(\.\d+)?(-[A-Za-z0-9]+)?)/.exec(version); if (!match?.groups) { - throw new Error( + throw new NonReportableError( `Ruby version file ${rubyVersionUri.fsPath} contains invalid format. Expected (engine-)?version, got ${version}`, ); } @@ -433,7 +439,7 @@ export class Chruby extends VersionManager { } private rubyVersionError() { - return new Error( + return new NonReportableError( `Cannot find .ruby-version file. Please specify the Ruby version in a .ruby-version either in ${this.bundleUri.fsPath} or in a parent directory`, ); diff --git a/vscode/src/ruby/custom.ts b/vscode/src/ruby/custom.ts index c4564c7946..d95b403746 100644 --- a/vscode/src/ruby/custom.ts +++ b/vscode/src/ruby/custom.ts @@ -1,6 +1,6 @@ import * as vscode from "vscode"; -import { VersionManager, ActivationResult } from "./versionManager"; +import { VersionManager, ActivationResult, NonReportableError } from "./versionManager"; // Custom // @@ -24,7 +24,7 @@ export class Custom extends VersionManager { const customCommand: string | undefined = configuration.get("customRubyCommand"); if (customCommand === undefined) { - throw new Error( + throw new NonReportableError( "The customRubyCommand configuration must be set when 'custom' is selected as the version manager. \ See the [README](https://shopify.github.io/ruby-lsp/version-managers.html) for instructions.", ); diff --git a/vscode/src/ruby/mise.ts b/vscode/src/ruby/mise.ts index 2c647ed4de..aa65f18666 100644 --- a/vscode/src/ruby/mise.ts +++ b/vscode/src/ruby/mise.ts @@ -2,7 +2,7 @@ import os from "os"; import * as vscode from "vscode"; -import { VersionManager, ActivationResult } from "./versionManager"; +import { VersionManager, ActivationResult, NonReportableError } from "./versionManager"; // Mise (mise en place) is a manager for dev tools, environment variables and tasks // @@ -33,7 +33,9 @@ export class Mise extends VersionManager { await vscode.workspace.fs.stat(configuredPath); return configuredPath; } catch (_error: any) { - throw new Error(`Mise executable configured as ${configuredPath.fsPath}, but that file doesn't exist`); + throw new NonReportableError( + `Mise executable configured as ${configuredPath.fsPath}, but that file doesn't exist`, + ); } } @@ -57,7 +59,7 @@ export class Mise extends VersionManager { } } - throw new Error( + throw new NonReportableError( `The Ruby LSP version manager is configured to be Mise, but could not find Mise installation. Searched in ${possiblePaths.join(", ")}`, ); diff --git a/vscode/src/ruby/rbenv.ts b/vscode/src/ruby/rbenv.ts index 4c7308ca9d..35d6202926 100644 --- a/vscode/src/ruby/rbenv.ts +++ b/vscode/src/ruby/rbenv.ts @@ -1,6 +1,6 @@ import * as vscode from "vscode"; -import { VersionManager, ActivationResult } from "./versionManager"; +import { VersionManager, ActivationResult, NonReportableError } from "./versionManager"; // Seamlessly manage your app’s Ruby environment with rbenv. // @@ -36,7 +36,9 @@ export class Rbenv extends VersionManager { return path; } catch (_error: any) { - throw new Error(`The Ruby LSP version manager is configured to be rbenv, but ${path} does not exist`); + throw new NonReportableError( + `The Ruby LSP version manager is configured to be rbenv, but ${path} does not exist`, + ); } } } diff --git a/vscode/src/ruby/rv.ts b/vscode/src/ruby/rv.ts index 41f5828ab9..bd55f33674 100644 --- a/vscode/src/ruby/rv.ts +++ b/vscode/src/ruby/rv.ts @@ -1,6 +1,6 @@ import * as vscode from "vscode"; -import { VersionManager, ActivationResult } from "./versionManager"; +import { VersionManager, ActivationResult, NonReportableError } from "./versionManager"; // Manage your Ruby environment with rv // @@ -40,7 +40,7 @@ export class Rv extends VersionManager { await vscode.workspace.fs.stat(vscode.Uri.file(path)); return path; } catch (_error: any) { - throw new Error(`The Ruby LSP version manager is configured to be rv, but ${path} does not exist`); + throw new NonReportableError(`The Ruby LSP version manager is configured to be rv, but ${path} does not exist`); } } } diff --git a/vscode/src/ruby/rvm.ts b/vscode/src/ruby/rvm.ts index 66f508db0c..fe1c3e37db 100644 --- a/vscode/src/ruby/rvm.ts +++ b/vscode/src/ruby/rvm.ts @@ -2,7 +2,7 @@ import os from "os"; import * as vscode from "vscode"; -import { ActivationResult, VersionManager } from "./versionManager"; +import { ActivationResult, NonReportableError, VersionManager } from "./versionManager"; // Ruby enVironment Manager. It manages Ruby application environments and enables switching between them. // Learn more: @@ -43,7 +43,7 @@ export class Rvm extends VersionManager { } } - throw new Error( + throw new NonReportableError( `Cannot find RVM installation directory. Searched in ${possiblePaths.map((uri) => uri.fsPath).join(",")}`, ); } diff --git a/vscode/src/ruby/shadowenv.ts b/vscode/src/ruby/shadowenv.ts index 38da3e87d2..9649685d34 100644 --- a/vscode/src/ruby/shadowenv.ts +++ b/vscode/src/ruby/shadowenv.ts @@ -15,7 +15,7 @@ export class Shadowenv extends VersionManager { try { await vscode.workspace.fs.stat(vscode.Uri.joinPath(this.bundleUri, ".shadowenv.d")); } catch (_error: any) { - throw new Error( + throw new NonReportableError( "The Ruby LSP version manager is configured to be shadowenv, \ but no .shadowenv.d directory was found in the workspace", ); @@ -58,7 +58,7 @@ export class Shadowenv extends VersionManager { try { await asyncExec("shadowenv --version"); } catch (_error: any) { - throw new Error( + throw new NonReportableError( `Shadowenv executable not found. Ensure it is installed and available in the PATH. This error may happen if your shell configuration is failing to be sourced from the editor or if another extension is mutating the process PATH.`, @@ -66,7 +66,7 @@ export class Shadowenv extends VersionManager { } // If it failed for some other reason, present the error to the user - throw new Error(`Failed to activate Ruby environment with Shadowenv: ${error.message}`); + throw new NonReportableError(`Failed to activate Ruby environment with Shadowenv: ${error.message}`); } } }