usebruno/bruno · warning · Error
${filename} file already exists
Error message
${filename} file already exists What it means
Thrown by 'renderer:create-dotenv-file' when fs.existsSync(dotEnvPath) is true — the dotenv file already exists, and create refuses to overwrite. dotEnvPath is path.join(collectionPathname, filename). The filename was already validated (error 197) and the path confirmed to be inside a collection.
Source
Thrown at packages/bruno-electron/src/ipc/collection.js:904
} catch (error) {
console.error('Error saving .env file:', error);
return Promise.reject(error);
}
});
// Create .env file for collection
ipcMain.handle('renderer:create-dotenv-file', async (event, collectionPathname, filename = '.env') => {
try {
if (!isValidDotEnvFilename(filename)) {
throw new Error('Invalid .env filename');
}
validatePathIsInsideCollection(collectionPathname);
const dotEnvPath = path.join(collectionPathname, filename);
if (fs.existsSync(dotEnvPath)) {
throw new Error(`${filename} file already exists`);
}
await writeFile(dotEnvPath, '');
return { success: true, filename };
} catch (error) {
console.error('Error creating .env file:', error);
return Promise.reject(error);
}
});
// Delete .env file for collection
ipcMain.handle('renderer:delete-dotenv-file', async (event, collectionPathname, filename = '.env') => {
try {
if (!isValidDotEnvFilename(filename)) {
throw new Error('Invalid .env filename');
}
View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Check existence before creating; if the file exists, open/edit it instead of creating.
- Prompt the user to overwrite (delete then create) or pick a different name.
- Treat 'already exists' as a non-error and route the user to editing the existing file.
Defensive patterns
Strategy: validation
Validate before calling
const candidate = path.join(collectionPathname, filename);
if (await window.ipcRenderer.invoke('renderer:file-exists', candidate)) {
// already exists — route to edit instead of create
} Try / catch
try {
await window.ipcRenderer.invoke('renderer:create-dotenv-file', collectionPath, filename);
} catch (e) {
if (/file already exists/.test(e.message)) {
await openDotEnvEditor(collectionPath, filename);
} else throw e;
} Prevention
- Check existence before creating; switch to edit mode if the file is present.
- Treat 'already exists' as a soft state, not an error, in the UI.
- Watch for case-insensitive collisions on Windows/macOS.
When it happens
Trigger: Creating a dotenv file whose name already exists in the collection root. Repeated create after a previous create succeeded. Case-fold collision on Windows/macOS.
Common situations: User clicks 'Create .env' twice. Bulk import that creates the file then the UI retries. Case-insensitive collision between '.env.Local' and '.env.local'.
Related errors
- ${request.filename} is not a valid filename
- A file with the name "${finalFilename}" already exists in th
- environment: ${newEnvFilePath} already exists
- Invalid .env filename
- path: ${pathname} does not exist
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/46bfc7d4b52b8976.
Report an issue: GitHub.