From 1e679cdcae743cb6f8625a551a2198df61b50c46 Mon Sep 17 00:00:00 2001 From: Daniel Alejandro Coll Tejeda <62675074+macarronesc@users.noreply.github.com> Date: Sun, 23 Nov 2025 16:36:18 +0000 Subject: [PATCH 1/2] Fix Issue Gemini CLI fails on Node.js v20+ with "URL.parse is not a function" Fixes #13615 --- packages/cli/src/config/extensions/github.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/config/extensions/github.ts b/packages/cli/src/config/extensions/github.ts index 187e790f2a3..9f865b1e1e9 100644 --- a/packages/cli/src/config/extensions/github.ts +++ b/packages/cli/src/config/extensions/github.ts @@ -89,7 +89,14 @@ export function tryParseGithubUrl(source: string): GithubRepoInfo | null { source = source.replace('git@github.com:', ''); } // Default to a github repo path, so `source` can be just an org/repo - const parsedUrl = URL.parse(source, 'https://github.com'); + let parsedUrl; + try { + // Usamos el constructor estándar compatible con versiones viejas + parsedUrl = new URL(source, 'https://github.com'); + } catch (e) { + parsedUrl = null; + } + if (!parsedUrl) { throw new Error(`Invalid repo URL: ${source}`); } From 19161f0a74cef765dc07b3ea0e5f7fb4fb77b7c2 Mon Sep 17 00:00:00 2001 From: Daniel Alejandro Coll Tejeda <62675074+macarronesc@users.noreply.github.com> Date: Sun, 23 Nov 2025 16:48:09 +0000 Subject: [PATCH 2/2] Added TypeError --- packages/cli/src/config/extensions/github.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/config/extensions/github.ts b/packages/cli/src/config/extensions/github.ts index 9f865b1e1e9..4d0c4409a9a 100644 --- a/packages/cli/src/config/extensions/github.ts +++ b/packages/cli/src/config/extensions/github.ts @@ -89,12 +89,14 @@ export function tryParseGithubUrl(source: string): GithubRepoInfo | null { source = source.replace('git@github.com:', ''); } // Default to a github repo path, so `source` can be just an org/repo - let parsedUrl; + let parsedUrl: URL; try { - // Usamos el constructor estándar compatible con versiones viejas + // Use the standard URL constructor for backward compatibility. parsedUrl = new URL(source, 'https://github.com'); } catch (e) { - parsedUrl = null; + // Throw a TypeError to maintain a consistent error contract for invalid URLs. + // This avoids a breaking change for consumers who might expect a TypeError. + throw new TypeError(`Invalid repo URL: ${source}`, { cause: e }); } if (!parsedUrl) {