Fixing Remote Path Mayhem: Backslashes vs. Forward Slashes

Fixing Path Separator Issues in Cursor AI’s SQLite Database

Issue Description

Cursor AI occasionally stores Windows-style backslash paths (\) instead of Unix-style forward slashes (/) for remote SSH workspace files. This can cause issues with file handling and navigation.

Location of the Issue

The path information is stored in SQLite database:

  • Path: %APPDATA%\Cursor\User\workspaceStorage\{workspace-id}\state.vscdb
  • Table: ItemTable
  • Key locations:
    1. composer.composerData (JSON field)
    2. memento/workbench.parts.editor (JSON field)

Diagnostic Commands

1. Check Tables

^^^powershell
sqlite3 state.vscdb “.tables”
^^^

2. Find Problematic Paths

^^^powershell

Check for backslash paths

sqlite3 state.vscdb “.mode line” “SELECT key, value
FROM ItemTable
WHERE value LIKE ‘%\var\www%’;”

Check specific composer data

sqlite3 state.vscdb “.mode line” “SELECT key, value
FROM ItemTable
WHERE key = ‘composer.composerData’;”
^^^

Fix Commands

1. Always Backup First

^^^powershell
Copy-Item state.vscdb state.vscdb.backup
^^^

2. Fix Composer Data

^^^powershell

Fix specific composer entry

sqlite3 state.vscdb "
UPDATE ItemTable
SET value = json_replace(
value,
‘$.allComposers[4].forceMode[0].fsPath’,
‘/var/www/html/autopop.icybox.de/doc/prd/prd-workflow-template-v02.md’
)
WHERE key = ‘composer.composerData’;"
^^^

3. Fix Workbench Editor State

^^^powershell

Fix workbench paths

sqlite3 state.vscdb "
UPDATE ItemTable
SET value = REPLACE(
value,
‘\\var\\www\\html\\autopop.icybox.de\\doc’,
‘/var/www/html/autopop.icybox.de/doc’
)
WHERE key = ‘memento/workbench.parts.editor’;"
^^^

Verification Commands

1. Check Composer Data

^^^powershell
sqlite3 state.vscdb “.mode line” “SELECT json_extract(value, ‘$.allComposers[4].forceMode[0].fsPath’) as current_path,
json_extract(value, ‘$.allComposers[4].forceMode[0].path’) as reference_path
FROM ItemTable
WHERE key = ‘composer.composerData’;”
^^^

2. Check for Any Remaining Backslash Paths

^^^powershell
sqlite3 state.vscdb “.mode line” “SELECT key, value
FROM ItemTable
WHERE value LIKE ‘%\var\www\html\autopop%’
OR value LIKE ‘%\\var\\www\\html\\autopop%’;”
^^^

Important Notes

  1. Always make a backup before modifying the SQLite database
  2. Close Cursor AI before making changes
  3. The database structure uses both ItemTable and cursorDiskKV tables
  4. Path information can be stored in multiple formats:
    • Direct paths with forward/backslashes
    • URI encoded paths (vscode-remote://ssh-remote%2B…)
    • JSON encoded paths in configuration objects

Troubleshooting

If issues persist:

  1. Check if Cursor AI is completely closed
  2. Verify the workspace ID is correct
  3. Ensure all paths in the database are consistent
  4. Restart Cursor AI after making changes

Prevention

Currently, there’s no direct way to prevent Cursor AI from occasionally storing Windows-style paths. The issue seems to occur during the translation between local Windows environment and remote SSH connections.

I have just created a GPT to guide users to fix the path issue, it offers a more smooth user-friendly flow

As it is hard to predict the outcome, it is always a good idea to backup first!