{"record":{"id":"fd4f8fafdeb58dd1","repo":"windmill-labs/windmill","slug":"cannot-fetch-backend-version-no-active-workspace","errorCode":null,"errorMessage":"Cannot fetch backend version: no active workspace selected, choose one to pick a remote to fetch version of","messagePattern":"Cannot fetch backend version: no active workspace selected, choose one to pick a remote to fetch version of","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"cli/src/main.ts","lineNumber":253,"sourceCode":"        console.log(\"CLI is up to date\");\n      }\n    } catch (e) {\n      console.warn(\n        `Cannot fetch latest CLI version on npmjs to check if up-to-date: ${e}`\n      );\n    }\n    const workspace = await getActiveWorkspace(opts as GlobalOptions);\n    if (workspace) {\n      try {\n        const backendVersion = await fetchVersion(workspace.remote);\n        console.log(\"Backend Version: \" + backendVersion);\n      } catch (e) {\n        console.warn(\n          `Cannot fetch backend version from ${workspace.remote} (workspace: ${workspace.name}): ${e}`\n        );\n      }\n    } else {\n      console.warn(\n        \"Cannot fetch backend version: no active workspace selected, choose one to pick a remote to fetch version of\"\n      );\n    }\n  })\n  .command(\n    \"upgrade\",\n    new UpgradeCommand({\n      provider: new NpmProvider({ package: \"windmill-cli\" }),\n    }).error((e: any) => {\n      log.error(e);\n      log.info(\n        \"Try running with sudo and otherwise check the result of the command: npm uninstall windmill-cli && npm install -g windmill-cli\"\n      );\n    })\n  )\n  .command(\n    \"completions\",\n    new Command()","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/main.ts#L235-L271","documentation":"When printing the backend version, main.ts first resolves the active workspace via getActiveWorkspace. If none is selected (or the workspace store is empty/corrupt), it prints this console.warn instead of attempting a fetch, telling the user to select a workspace so it knows which remote to query. It is a usage-state warning, not a network failure.","triggerScenarios":"Running the backend-version command (or any flow that reads the active workspace) with no workspace currently selected — never running `wmill workspace add`/`switch`, an unset WMILL_WORKSPACE env, or a missing/corrupt workspaces store.","commonSituations":"Fresh install of the CLI; CI container with a new $HOME so ~/.wmill/workspaces.yaml doesn't exist; switching machines without migrating workspace credentials; WMILL_WORKSPACE set to a nonexistent name.","solutions":["Add a workspace: `wmill workspace add <name> <remote> <token>`.","Select one: `wmill workspace switch <name>` (or export WMILL_WORKSPACE=<name>).","In CI, create/select the workspace non-interactively before commands that need it.","Check ~/.wmill/workspaces.yaml exists and is valid if you believe a workspace was configured."],"exampleFix":"// before\nwmill version\n// Cannot fetch backend version: no active workspace selected...\n\n// after\nwmill workspace add prod https://windmill.corp $WMILL_TOKEN\nwmill workspace switch prod\nwmill version","handlingStrategy":"validation","validationCode":"import { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nconst store = `${homedir()}/.wmill/workspaces.yaml`;\nif (!existsSync(store)) {\n  throw new Error(\"no wmill workspaces configured — run `wmill workspace add <name> <remote> <token>` and `wmill workspace switch <name>`\");\n}","typeGuard":null,"tryCatchPattern":"const active = process.env.WMILL_WORKSPACE;\nif (!active) {\n  console.error(\"set WMILL_WORKSPACE or run `wmill workspace switch <name>` before commands that query the backend\");\n  process.exit(1);\n}","preventionTips":["Persist WMILL_WORKSPACE (or run `wmill workspace switch`) in shell rc and CI setup steps","Create the workspace non-interactively at the start of CI jobs","Migrate ~/.wmill/workspaces.yaml when moving machines or containers","Verify the configured workspace name exists with `wmill workspace list`"],"tags":["cli","workspace-config","missing-configuration"],"backgroundTag":"no-active-workspace","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}