The Write and StrReplace tools (used by the AI to create and edit files) consistently return “Invalid arguments” when the workspace is opened via Remote-SSH from a Mac to a Windows host. The same tools work when the workspace is opened locally on either Mac or Windows. Read and terminal/shell tools work over SSH; only Write and StrReplace fail.
Steps to Reproduce
On a Mac, connect to a Windows machine using Cursor’s Remote-SSH (Remote - SSH) and open any project folder on the Windows host.
Start a new chat and ask the AI to create a file (e.g. “Create a file at test.txt in the project root with content ‘hello’”).
Ask the AI to edit that file (e.g. “Replace ‘hello’ with ‘world’ in that file”).
Observe: the AI’s Write and StrReplace tool calls return “Invalid arguments”. The same test run locally on the Mac or locally on the Windows machine succeeds.
Expected Behavior
Write and StrReplace should succeed over Remote-SSH to a Windows host, just as they do when the workspace is opened locally on Mac or Windows. File paths (relative or absolute) should be accepted and the file created/updated.
Workaround: When using Remote-SSH to Windows, use terminal commands (e.g. PowerShell Set-Content) to create/overwrite files, or open the folder locally on the Windows machine when the AI needs to use Write/StrReplace.
Hey, thanks for the detailed report. This is really helpful.
This is a known regression related to parsing Windows paths in Remote SSH sessions. The root cause is a UriError that happens when the agent tries to resolve file paths over an SSH connection to a Windows host. This has been reported a few times already, and it tends to come back in different versions.
Temporary workaround: try switching the bottom panel from Terminal to Output before running agent commands. In some cases this prevents the path parsing issue because the terminal context does not get collected.
Temporary workaround: try switching the bottom panel from Terminal to Output before running agent commands. In some cases this prevents the path parsing issue because the terminal context does not get collected.
Thanks i’m not seeing how this changes anything since i’m running into this bug in agent chats. The work around that’s worked has been setting up the following rule in cursorrules. Imperfect:
File Edits Fallback (Remote-SSH to Windows)
Why this is in place: When this workspace is opened via Remote-SSH from a Mac to a Windows host, Cursor’s Write and StrReplace tools consistently return “Invalid arguments.” The same tools work when the workspace is opened locally (Mac or Windows). This is a known Cursor limitation in the Remote-SSH (Mac to Windows) scenario. Until Cursor fixes it, use the fallback below when the tools fail.
Conditional behavior: Use Write and StrReplace as usual when they succeed (e.g. when working locally). Only when Write or StrReplace return “Invalid arguments” should you retry using PowerShell as described below.
Fallback procedure: If the Write or StrReplace tools return “Invalid arguments”:
Retry using PowerShell from the project (workspace) root.
Create/overwrite:Set-Content -Path "path\to\file" -Value "content". For multi-line content use an array of lines or a here-string (@" ... "@); prefer single quotes to avoid escaping.
Replace text:(Get-Content -Raw "path\to\file") -replace 'old','new' | Set-Content "path\to\file". When the text to replace contains regex metacharacters (e.g. .[]()*$), use [regex]::Escape('old') for the first argument: -replace [regex]::Escape('old'), 'new'. Omit -NoNewline unless you intend to strip a trailing newline (otherwise the file may lose its final newline).
Use paths relative to project root in both cases.
Alternatively, i’ve moved back to running cursor locally where needed.
To your questions:
When Write/StrReplace crashes, do you see a UriError in the devtools console (Help > Toggle Developer Tools > Console tab)?
No i don’t see UriError.
Is the Terminal panel open or visible when the error happens?
No the terminal open or visible when the error happens.
Which Remote SSH extension are you using, Anysphere or Microsoft? (CMD+Shift+X > search “Remote-SSH” > check the publisher)
Anysphere. Had issues getting microsoft to work initially.
Hi guys. Same issue — the strreplace and write tools are returning “invalid arguments.” Rolling back to version 2.2.44 fixed it. Are the developers aware of this?