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

  1. Check existence before creating; if the file exists, open/edit it instead of creating.
  2. Prompt the user to overwrite (delete then create) or pick a different name.
  3. 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

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


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/46bfc7d4b52b8976. Report an issue: GitHub.