usebruno/bruno · warning · Error
${filename} file already exists
Error message
${filename} file already exists What it means
In `renderer:create-workspace-dotenv-file`, after validation passes, `fs.existsSync(dotEnvPath)` is checked. If the file is already present the handler refuses - create means create, it will not overwrite an existing env file.
Source
Thrown at packages/bruno-electron/src/ipc/global-environments.js:220
return Promise.reject(error);
}
});
// Create workspace .env file
ipcMain.handle('renderer:create-workspace-dotenv-file', async (event, { workspacePath, filename = '.env' }) => {
try {
if (!workspacePath) {
throw new Error('Workspace path is required');
}
if (!isValidDotEnvFilename(filename)) {
throw new Error('Invalid .env filename');
}
const dotEnvPath = path.join(workspacePath, filename);
if (fs.existsSync(dotEnvPath)) {
throw new Error(`${filename} file already exists`);
}
await writeFile(dotEnvPath, '');
return { success: true };
} catch (error) {
console.error('Error creating workspace .env file:', error);
return Promise.reject(error);
}
});
// Delete workspace .env file
ipcMain.handle('renderer:delete-workspace-dotenv-file', async (event, { workspacePath, filename = '.env' }) => {
try {
if (!workspacePath) {
throw new Error('Workspace path is required');
}
View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Use the save/edit flow (save-workspace-dotenv-raw) instead of create when the file exists.
- Delete the existing file first if you truly want to recreate it.
- Check existence in the UI and hide or disable Create when present.
Example fix
// before
await invoke('renderer:create-workspace-dotenv-file', { workspacePath, filename: '.env' }); // throws if exists
// after - edit instead of create
await invoke('renderer:save-workspace-dotenv-raw', { workspacePath, content: '', filename: '.env' }); Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs'), path = require('path');
const exists = (workspacePath, filename) => fs.existsSync(path.join(workspacePath, filename)); Prevention
- Refresh the file list before offering Create.
- Switch the UI to Edit mode when the file is present.
- Handle the 'already exists' rejection by routing to the save flow.
When it happens
Trigger: User clicks Create when `.env` (or the named variant) already exists in the workspace; a previous create left the file; a concurrent double-submit.
Common situations: The file is hidden in the UI so the user doesn't realize it exists; re-running create after a partial run.
Related errors
- ${filename} file does not exist
- Failed to export ${environmentType} environments.
- ${request.filename} is not a valid filename
- path: ${pathname} does not exist
- Source path: ${sourcePathname} does not exist
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/14687ac77c74b1f6.
Report an issue: GitHub.