usebruno/bruno · error · Error

directory: ${dir} already exists

Error message

directory: ${dir} already exists

What it means

Error "directory: ${dir} already exists" thrown in usebruno/bruno.

Source

Thrown at packages/bruno-cli/src/utils/filesystem.js:77

};

const hasJsonExtension = (filename) => {
  if (!filename || typeof filename !== 'string') return false;
  return ['json'].some((ext) => filename.toLowerCase().endsWith(`.${ext}`));
};

const hasBruExtension = (filename) => {
  if (!filename || typeof filename !== 'string') return false;
  return ['bru'].some((ext) => filename.toLowerCase().endsWith(`.${ext}`));
};

const createDirectory = async (dir) => {
  if (!dir) {
    throw new Error(`directory: path is null`);
  }

  if (fs.existsSync(dir)) {
    throw new Error(`directory: ${dir} already exists`);
  }

  return fs.mkdirSync(dir);
};

const searchForFiles = (dir, extension) => {
  let results = [];
  const files = fs.readdirSync(dir);
  for (const file of files) {
    const filePath = path.join(dir, file);
    const stat = fs.statSync(filePath);
    if (stat.isDirectory()) {
      results = results.concat(searchForFiles(filePath, extension));
    } else if (path.extname(file) === extension) {
      results.push(filePath);
    }
  }
  return results;

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Choose a directory name that does not already exist, or remove/rename the existing one.
  2. Use the existing directory if creation was not actually needed.

When it happens

Trigger: Thrown at packages/bruno-cli/src/utils/filesystem.js:77 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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