windmill-labs/windmill · error
File already exists: + scriptMetadataFileFullPath
Error message
File already exists: + scriptMetadataFileFullPath
What it means
The same bootstrap guard as the code file, applied to the metadata file (`<path>.script.yaml`). If that metadata file already exists on disk, bootstrap throws 'File already exists' for it. Like the code-file check, it rethrows only its own deliberate error and lets ENOENT pass.
Source
Thrown at cli/src/commands/script/script.ts:1656
const config = await readConfigFile();
const extension = filePathExtensionFromContentType(
resolvedLanguage,
config.defaultTs
);
const scriptCodeFileFullPath = scriptPath + extension;
const scriptMetadataFileFullPath = scriptPath + ".script.yaml";
try {
await stat(scriptCodeFileFullPath);
throw new Error("File already exists: " + scriptCodeFileFullPath);
} catch (e: any) {
if (e.message?.startsWith("File already exists")) throw e;
}
try {
await stat(scriptMetadataFileFullPath);
throw new Error("File already exists: " + scriptMetadataFileFullPath);
} catch (e: any) {
if (e.message?.startsWith("File already exists")) throw e;
}
const scriptMetadata = defaultScriptMetadata();
if (opts.summary !== undefined) {
scriptMetadata.summary = opts.summary;
}
if (opts.description !== undefined) {
scriptMetadata.description = opts.description;
}
const scriptInitialMetadataYaml = yamlStringify(
scriptMetadata as Record<string, any>,
yamlOptions
);
const parentDir = path.dirname(scriptCodeFileFullPath);View on GitHub (pinned to e474e8803c)
Solutions
- Remove or rename the existing `.script.yaml` if bootstrapping fresh.
- Use `wmill script pull` instead of bootstrap to sync an already-deployed script.
- Choose a different path for the new script.
- Manually edit the existing metadata instead of regenerating it.
Example fix
// before wmill script bootstrap f/my_script go # my_script.script.yaml exists from pull // after wmill script pull f/my_script # or: mv f/my_script.script.yaml /tmp/backup.yaml
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'fs';
const metaFile = scriptPath + '.script.yaml';
if (existsSync(metaFile)) {
// already synced/deployed — pull instead of bootstrap
console.error(`${metaFile} exists; use 'wmill script pull' to sync.`);
process.exit(1);
} Try / catch
try {
await wmill.script.bootstrap(p, lang);
} catch (e) {
if (/File already exists: .*\.script\.yaml/.test(String(e.message))) {
console.error('Metadata already present — edit it or pull from the instance.');
}
throw e;
} Prevention
- After `wmill script pull`, never re-bootstrap the same path.
- Commit `.script.yaml` files; edit them directly instead of regenerating.
- Check for existing `.script.yaml` siblings before scaffolding a new script.
When it happens
Trigger: `wmill script bootstrap <path> <lang>` when `<path>.script.yaml` already exists — e.g. the script was previously pulled/synced with `wmill script pull`, or a previous bootstrap created the metadata but the code file was deleted.
Common situations: Bootstrapping a script that was already synced from the instance via `wmill sync` or `pull`; re-running bootstrap after manually deleting only the code file; working in a repo where `.script.yaml` files are committed.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- File already exists: + scriptCodeFileFullPath
- File not found: ${filePath}
- Workspace folder not found, are you in the right directory?
- Directory not found: ${targetDirectory}
- Path is not a directory: ${targetDirectory}
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/0189452738f647c0.
Report an issue: GitHub.