deepseek-ai/deepseek-harness · error · Error
File already exists at
Error message
File already exists at: ${target.displayPath}. Cannot overwrite files using command `create`. What it means
Create-overwrite guard in createFile: statExisting confirmed a file already exists at the target, and create is deliberately non-destructive. The guard fires before any write; use the editing commands to change existing content.
Solutions
- Use str_replace or insert to modify the existing file
- Choose a different path for the new file
- Delete or move the existing file first if replacement is intended
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/fs/tool-str-replace-editor/src/index.ts:250 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24).
Data as JSON: /api/errors/397afb088bd513e4.
Report an issue: GitHub.
Appendix: source
Thrown at packages/fs/tool-str-replace-editor/src/index.ts:250
throw new FsError(`cannot view "${target.displayPath}": not a regular file or directory`, 'FS_NOT_REGULAR_FILE')
}
const content = await ctx.fs.readText(target, exec.signal)
ctx.emit('fs/observed', target, { kind: 'present', version: info.version }, exec)
return formatFileView(target.displayPath, content, maxOutputChars, viewRange)
}
async function createFile(
ctx: Context,
policy: MutationPolicy,
path: string,
fileText: string | undefined,
exec: ToolRunContext,
): Promise<string> {
const content = requiredForCommand(fileText, 'file_text', 'create')
const sandboxPolicy = policy.resolve(exec)
const target = await resolveTarget(ctx, path, exec.signal)
if (await ctx.fs.stat(target, exec.signal) !== undefined) {
throw new Error(`File already exists at: ${target.displayPath}. Cannot overwrite files using command \`create\`.`)
}
const intent = await ctx.waterfall(
'fs/write-intent',
target,
exec,
() => ({ kind: 'createIfAbsent' } as const),
)
let outcome
try {
outcome = await ctx.fs.writeText(
target,
content,
intent,
exec.signal,
sandboxPolicy,
)
} catch (error: unknown) {
throw policy.mapError(error, sandboxPolicy)View on GitHub (pinned to b150a551b8)