WSL: `cursor .` fails with `spawn wsl.exe ENOENT` because WSL launcher does not export PATH via WSLENV

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Summary

When launching Cursor from inside WSL using the command:

cursor .

Cursor reliably fails to connect to WSL with:

Error installing Cursor server A system error occurred (spawn wsl.exe ENOENT)

This happens even though:

  • wsl.exe exists and works from Windows
  • Cursor.exe can connect to WSL when launched from the Start Menu
  • PATH is correctly set on both Windows and inside WSL

The root cause is that the official Cursor WSL launcher script (resources/app/bin/cursor) does not export PATH via WSLENV, so Windows processes launched from inside WSL cannot see wsl.exe on PATH.


Environment

  • Windows 11 (Insider build; also reproducible on stable)
  • WSL2 (Ubuntu)
  • Cursor Version: 2.x (User Installer)
  • Shells tested: bash, zsh
  • Reproducible across reboots and after reinstalling Cursor + WSL servers

Reproduction Steps

  1. Open WSL2 Ubuntu.

  2. Navigate to any WSL-native folder:

    cd ~/code/myproject
    
  3. Run:

    cursor .
    
  4. Observe failure:

    • Popup:

      Connection to Cursor server failed: spawn wsl.exe ENOENT
      
    • Status bar: Disconnected from WSL: ubuntu

    • Output → Remote - WSL:

      Error installing Cursor server A system error occurred (spawn wsl.exe ENOENT)
      
  5. Launch Cursor from the Windows Start Menu → Cursor connects to WSL normally.

  6. Inside WSL:

    cmd.exe /c echo OK
    wsl.exe -l -v
    

    both work → confirms that wsl.exe exists and that PATH is correct from Windows and WSL.


Root Cause (confirmed)

In the official Cursor WSL launcher:

C:\Users\<user>\AppData\Local\Programs\cursor\resources\app\bin\cursor

there is a line:

export WSLENV="ELECTRON_RUN_AS_NODE/w:$WSLENV"

This does not export PATH to Windows when WSL launches Cursor.exe.

As a result, the Windows process spawned from WSL inherits no PATH (or an incomplete one), and therefore cannot find:

C:\Windows\System32\wsl.exe

Even after PATH is corrected in both Windows and WSL, the launcher script prevents PATH from being passed through WSLENV unless explicitly added.


Minimal Patch (verified fix)

Modify this line in the launcher script:

Current (buggy):

export WSLENV="ELECTRON_RUN_AS_NODE/w:$WSLENV"

Correct (working):

export WSLENV="ELECTRON_RUN_AS_NODE/w:PATH/l:$WSLENV"

Explanation:

  • PATH/l → export WSL PATH to Windows, converting Linux paths to Windows paths.
  • After this change, cursor . launches Cursor correctly, and the WSL bridge can spawn wsl.exe reliably.

Evidence that this fixes the issue

After applying the patch:

  • cursor . from WSL launches Cursor in a WSL session (WSL: Ubuntu).

  • No ENOENT popups.

  • Remote-WSL log shows:

    Successfully connected to Cursor server...
    
  • The issue does not recur until Cursor updates and overwrites the launcher script.

This behavior has been reproduced and confirmed multiple times.


Suggested Fix for Cursor Team

Include PATH/l in the launcher’s WSLENV export:

export WSLENV="ELECTRON_RUN_AS_NODE/w:PATH/l:$WSLENV"

Or, better:

  • Add PATH detection logic in the launcher.
  • Or include PATH/l in the packaged script by default.
  • Or modify the WSL Remote extension so that PATH export is handled automatically.

Impact

This issue:

  • Breaks cursor . for all WSL users whose WSL environment doesn’t implicitly export PATH.
  • Causes confusing, persistent spawn wsl.exe ENOENT failures.
  • Returns after every Cursor update unless patched manually.
  • Makes WSL development unreliable and creates a poor out-of-box experience.

Request

Please incorporate the single-line WSLENV fix into the official Cursor WSL launcher so that:

  • cursor . works reliably,
  • updates do not regress the environment,
  • PATH is exported correctly by default,
  • and users no longer need to hand-patch the launcher after every update.

Thank you!

Steps to Reproduce

Reproduction Steps

Open WSL2 Ubuntu.

Navigate to any WSL-native folder:

cd ~/code/myproject

Run:

cursor .

Observe failure:

Popup:

Connection to Cursor server failed: spawn wsl.exe ENOENT

Status bar: Disconnected from WSL: ubuntu

Output → Remote - WSL:

Error installing Cursor server A system error occurred (spawn wsl.exe ENOENT)

Launch Cursor from the Windows Start Menu → Cursor connects to WSL normally.

Inside WSL:

cmd.exe /c echo OK
wsl.exe -l -v

both work → confirms that wsl.exe exists and that PATH is correct from Windows and WSL.

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.1.46 (user setup)
VSCode Version: 1.105.1
Commit: ab326d0767c02fb9847b342c43ea58275c4b1680
Date: 2025-12-02T03:59:29.283Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26200

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report. I’ll pass it to the team.

1 Like

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.