From b18ad775395efba40b99afbbde2049530f2ca540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Barreiro?= <52393857+BarreiroT@users.noreply.github.com> Date: Thu, 17 Jul 2025 03:22:01 +0200 Subject: [PATCH] Improve Claude Code errors and create Docs (#4968) * Create docs * Improve the Claude Code error messages * Replace with remote image --- .changeset/sweet-dingos-serve.md | 5 +++++ docs/provider-config/claude-code.mdx | 25 +++++++++++++++++++++ src/integrations/claude-code/run.ts | 33 ++++++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .changeset/sweet-dingos-serve.md diff --git a/.changeset/sweet-dingos-serve.md b/.changeset/sweet-dingos-serve.md new file mode 100644 index 00000000..555f71dc --- /dev/null +++ b/.changeset/sweet-dingos-serve.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Improve the Claude Code error messages diff --git a/docs/provider-config/claude-code.mdx b/docs/provider-config/claude-code.mdx index 76be0b07..8f47abae 100644 --- a/docs/provider-config/claude-code.mdx +++ b/docs/provider-config/claude-code.mdx @@ -32,6 +32,31 @@ First, you'll need to install and authenticate Claude Code on your system: /> +
+ + +On Windows, Cline supports integrating with Claude Code through WSL. +Windows doesn't support long commands, and Claude Code only accepts the system prompt through a flag, which means we can't properly prompt Claude through Claude Code. Anthropic is [working on a workaround to streamline this](https://github.com/anthropics/claude-code/issues/3411). + +1. **Make sure you have WSL set-up**. You can follow [this](https://code.visualstudio.com/docs/remote/wsl#_installation) guide to do it. + +2. **Open VSCode from WSL** and verify it's properly set-up. You should see an indicator in the bottom left that says "WSL". You can find an image of the indicator [here](https://code.visualstudio.com/docs/remote/wsl#_from-the-wsl-terminal). + +3. Install Cline within WSL and make sure it shows the following: + + + Indicator that an extension is installed on WSL + + +4. Clone or [move](https://stackoverflow.com/a/42586455) your project over to WSL + +5. Follow the [instructions on how to set up Claude Code normally](#setup), but from the WSL terminal. + + + ### Finding your Claude Code path If you're not sure where Claude Code is installed: diff --git a/src/integrations/claude-code/run.ts b/src/integrations/claude-code/run.ts index 02793390..140ac966 100644 --- a/src/integrations/claude-code/run.ts +++ b/src/integrations/claude-code/run.ts @@ -76,10 +76,39 @@ export async function* runClaudeCode(options: ClaudeCodeOptions): AsyncGenerator ) } } catch (err) { - // When the command fails, execa throws an error with the arguments, which include the whole system prompt. - // We want to log that, but not show it to the user. console.error(`Error during Claude Code execution:`, err) + if (err instanceof Error) { + if (err.message.includes("ENOENT")) { + throw new Error( + `Failed to find the Claude Code executable. +Make sure it's installed and available in your PATH or properly set in your provider settings.`, + { cause: err }, + ) + } + + if (err.message.includes("E2BIG")) { + throw new Error( + `Executing Claude Code failed due to a long system prompt. The maximum argument length is 131072 bytes. +Rules and workflows contribute to a longer system prompt, consider disabling some of them temporarily to reduce the length. +Anthropic is aware of this issue and is considering a fix: https://github.com/anthropics/claude-code/issues/3411. +`, + { cause: err }, + ) + } + + if (err.message.includes("ENAMETOOLONG")) { + throw new Error( + `Executing Claude Code failed due to a long system prompt. Windows has a limit of 8191 characters, which makes the integration with Cline not work properly. +Please check our docs on how to integrate Claude Code with Cline on Windows: https://docs.cline.bot/provider-config/claude-code#windows-setup. +Anthropic is aware of this issue and is considering a fix: https://github.com/anthropics/claude-code/issues/3411. +`, + { cause: err }, + ) + } + + // When the command fails, execa throws an error with the arguments, which include the whole system prompt. + // We want to log that, but not show it to the user. const startOfCommand = err.message.indexOf(": ") if (startOfCommand !== -1) { const messageWithoutCommand = err.message.slice(0, startOfCommand).trim()