{"record":{"id":"0189452738f647c0","repo":"windmill-labs/windmill","slug":"file-already-exists-scriptmetadatafilefullpath","errorCode":null,"errorMessage":"File already exists: + scriptMetadataFileFullPath","messagePattern":"File already exists: \\+ scriptMetadataFileFullPath","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/script/script.ts","lineNumber":1656,"sourceCode":"\n  const config = await readConfigFile();\n\n  const extension = filePathExtensionFromContentType(\n    resolvedLanguage,\n    config.defaultTs\n  );\n  const scriptCodeFileFullPath = scriptPath + extension;\n  const scriptMetadataFileFullPath = scriptPath + \".script.yaml\";\n\n  try {\n    await stat(scriptCodeFileFullPath);\n    throw new Error(\"File already exists: \" + scriptCodeFileFullPath);\n  } catch (e: any) {\n    if (e.message?.startsWith(\"File already exists\")) throw e;\n  }\n  try {\n    await stat(scriptMetadataFileFullPath);\n    throw new Error(\"File already exists: \" + scriptMetadataFileFullPath);\n  } catch (e: any) {\n    if (e.message?.startsWith(\"File already exists\")) throw e;\n  }\n\n  const scriptMetadata = defaultScriptMetadata();\n  if (opts.summary !== undefined) {\n    scriptMetadata.summary = opts.summary;\n  }\n  if (opts.description !== undefined) {\n    scriptMetadata.description = opts.description;\n  }\n\n  const scriptInitialMetadataYaml = yamlStringify(\n    scriptMetadata as Record<string, any>,\n    yamlOptions\n  );\n\n  const parentDir = path.dirname(scriptCodeFileFullPath);","sourceCodeStart":1638,"sourceCodeEnd":1674,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/script/script.ts#L1638-L1674","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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."],"exampleFix":"// before\nwmill script bootstrap f/my_script go   # my_script.script.yaml exists from pull\n// after\nwmill script pull f/my_script   # or: mv f/my_script.script.yaml /tmp/backup.yaml","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nconst metaFile = scriptPath + '.script.yaml';\nif (existsSync(metaFile)) {\n  // already synced/deployed — pull instead of bootstrap\n  console.error(`${metaFile} exists; use 'wmill script pull' to sync.`);\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await wmill.script.bootstrap(p, lang);\n} catch (e) {\n  if (/File already exists: .*\\.script\\.yaml/.test(String(e.message))) {\n    console.error('Metadata already present — edit it or pull from the instance.');\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["cli","filesystem","file-conflict","bootstrap"],"backgroundTag":"file-already-exists","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}