windmill-labs/windmill · error · Error

File already exists: ${filePath}

Error message

File already exists: ${filePath}

What it means

`wmill variable new` refuses to write its template because <path>.variable.yaml already exists locally; generating it would clobber the existing definition. The catch block re-throws this sentinel while letting ENOENT fall through to creation.

Source

Thrown at cli/src/commands/variable/variable.ts:58

        variables.map((x) => [
          x.path,
          x.is_secret ? "true" : "false",
          x.account ?? "-",
          x.value ?? "-",
        ])
      )
      .render();
  }
}

async function newVariable(opts: GlobalOptions, path: string) {
  if (!validatePath(path)) {
    return;
  }
  const filePath = path + ".variable.yaml";
  try {
    await stat(filePath);
    throw new Error("File already exists: " + filePath);
  } catch (e: any) {
    if (e.message?.startsWith("File already exists")) throw e;
  }
  const template: VariableFile = {
    value: "",
    is_secret: false,
    description: "",
  };
  await mkdir(dirname(filePath), { recursive: true });
  await writeFile(filePath, yamlStringify(template as Record<string, any>), {
    flag: "wx",
    encoding: "utf-8",
  });
  log.info(colors.green(`Created ${filePath}`));
}

async function get(opts: GlobalOptions & { json?: boolean }, path: string) {
  if (opts.json) log.setSilent(true);

View on GitHub (pinned to e474e8803c)

Solutions

  1. Pick a different variable path/name.
  2. Delete or rename the existing file, or edit it directly instead of re-running new.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cli/src/commands/variable/variable.ts:58 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/95b87345022bbf7d. Report an issue: GitHub.