jackwener/OpenCLI · error · CommandExecutionError
state.vscdb not found: ${TRAE_GLOBAL_STATE_DB}
Error message
state.vscdb not found: ${TRAE_GLOBAL_STATE_DB} What it means
Thrown by the recent-workspaces command when the global state DB file TRAE_GLOBAL_STATE_DB does not exist on disk. The command requires reading 'history.recentlyOpenedPathsList' from that SQLite DB, so without the file it cannot proceed.
Source
Thrown at clis/trae-solo/state-fs.js:130
},
});
// -------- recent-workspaces --------
cli({
site: 'trae-solo',
name: 'recent-workspaces',
access: 'read',
description: 'Show Trae SOLO\'s recently-opened workspaces (the File → Open Recent menu, stored under key "history.recentlyOpenedPathsList" in state.vscdb).',
domain: 'localhost',
browser: false,
strategy: Strategy.LOCAL,
args: [
{ name: 'limit', type: 'int', required: false, default: 20 },
],
columns: ['Index', 'Key', 'Kind', 'Path'],
func: async (args) => {
if (!fs.existsSync(TRAE_GLOBAL_STATE_DB)) {
throw new CommandExecutionError(`state.vscdb not found: ${TRAE_GLOBAL_STATE_DB}`, '');
}
const val = getValue(TRAE_GLOBAL_STATE_DB, 'history.recentlyOpenedPathsList');
if (!val) {
throw new EmptyResultError('trae-solo recent-workspaces', 'No recent workspaces recorded.');
}
const entries = val.entries || [];
if (!entries.length) {
throw new EmptyResultError('trae-solo recent-workspaces', 'history.recentlyOpenedPathsList has no entries.');
}
const limit = Number.isInteger(args.limit) && args.limit > 0 ? args.limit : 20;
return entries.slice(0, limit).map((e, i) => {
let kind = 'other', target = JSON.stringify(e).slice(0, 200);
if (e.folderUri) {
kind = 'folder';
target = decodeURI(String(e.folderUri).replace(/^file:\/\//, ''));
} else if (e.workspace && e.workspace.configPath) {
kind = 'workspace';
target = decodeURI(String(e.workspace.configPath).replace(/^file:\/\//, ''));View on GitHub (pinned to 49907e53dc)
Solutions
- Launch Trae at least once so it creates state.vscdb, then retry.
- Verify the DB path (print TRAE_GLOBAL_STATE_DB / the path in the message) and check it exists with ls.
- Point the CLI's Trae data-directory configuration at the profile that actually contains state.vscdb.
- If Trae is installed per-user, run the CLI as that user.
Example fix
// before opencli trae-solo recent-workspaces # fails: no Trae profile on this machine // after open trae # launch once to create state.vscdb opencli trae-solo recent-workspaces
Defensive patterns
Strategy: fallback
Validate before calling
const fs = require('fs');
if (!fs.existsSync(TRAE_GLOBAL_STATE_DB)) {
console.error(`Trae DB missing at ${TRAE_GLOBAL_STATE_DB}; launch Trae once or fix data dir`);
} Try / catch
try {
return await recentWorkspaces(args);
} catch (e) {
if (/state.vscdb not found/.test(e.message)) return workspacesList(args); // scan workspaceStorage instead
throw e;
} Prevention
- Ensure Trae has been launched at least once on this machine/user
- Verify the TRAE data directory configuration matches the installed profile
- Run the CLI as the same user that runs Trae
- Check the DB path with ls after any OS/Trae upgrade
When it happens
Trigger: Running recent-workspaces on a machine where Trae has never been launched, after Trae's data directory was deleted/moved, or when the CLI's configured Trae profile path does not match the installed version.
Common situations: Fresh OS/container without Trae installed; Trae installed for a different user; custom TRAE data dir env var pointing elsewhere; upgrading Trae changed the storage layout.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- settings.json not found: ${AG_SETTINGS_JSON}
- ${label} not found: ${p}
- workspaceStorage not found: ${TRAE_WORKSPACE_STORAGE}
- extensions.json not found: ${TRAE_EXTENSIONS_JSON}
- Verify command returned no metric for baseline
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/2389dff2ce9dbd4a.
Report an issue: GitHub.