usebruno/bruno · critical · Error
Failed to create default location
Error message
Failed to create default location
What it means
Thrown by resolveDefaultLocation when every candidate directory failed to create. Candidates are ~/Documents/bruno and the Electron userData dir; each is attempted with mkdirSync(recursive:true), and only if all throw does this fire. It signals a systemic inability to write to any user-writable location.
Source
Thrown at packages/bruno-electron/src/utils/default-location.js:26
* Returns the default location where new workspaces and collections are stored.
* Checks ~/Documents/bruno if available, otherwise falls back to the app's data directory
*/
function resolveDefaultLocation() {
const defaultPaths = [
path.join(app.getPath('documents'), BRUNO_DIR_NAME),
app.getPath('userData')
];
for (const dirPath of defaultPaths) {
try {
fs.mkdirSync(dirPath, { recursive: true });
return dirPath;
} catch (error) {
console.warn(`Failed to create directory at ${dirPath}:`, error.message);
}
}
throw new Error('Failed to create default location');
}
module.exports = { resolveDefaultLocation };
View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Check OS-level write permissions for the user's Documents and userData directories; grant write access or re-run with appropriate privileges.
- On Linux without a Documents path, set XDG_DOCUMENTS_DIR or a valid app.getPath('documents') override.
- Free disk space if the volume is full.
- As a last resort, point Bruno's userData to a writable explicit location via app.setPath('userData', ...).
Example fix
// before
for (const dirPath of defaultPaths) {
try {
fs.mkdirSync(dirPath, { recursive: true });
return dirPath;
} catch (error) {
console.warn(`Failed to create directory at ${dirPath}:`, error.message);
}
}
throw new Error('Failed to create default location');
// after: include os.tmpdir() fallback and surface root cause
const defaultPaths = [
path.join(app.getPath('documents'), BRUNO_DIR_NAME),
app.getPath('userData'),
path.join(os.tmpdir(), BRUNO_DIR_NAME)
]; Defensive patterns
Strategy: try-catch
Validate before calling
function canWrite(dir) {
try { fs.accessSync(dir, fs.constants.W_OK); return true; } catch { return false; }
}
const docs = app.getPath('documents');
const userData = app.getPath('userData');
if (!canWrite(path.dirname(docs)) && !canWrite(userData)) {
throw new Error('No writable default location; check permissions');
} Type guard
function isWritableDir(dir) {
try { fs.mkdirSync(dir, { recursive: true }); return true; }
catch { return false; }
} Try / catch
try {
return resolveDefaultLocation();
} catch (err) {
if (err.message === 'Failed to create default location') {
// prompt user to pick a writable directory, then app.setPath('userData', picked)
return await askUserForWritableLocation();
}
throw err;
} Prevention
- Ensure the OS user has write access to Documents and userData before first launch.
- On Linux, set XDG_DOCUMENTS_DIR and a running secret service.
- For sandboxed installs (Snap/Flatpak), grant the filesystem permission.
When it happens
Trigger: Both app.getPath('documents') and app.getPath('userData') are unwritable (permissions, read-only mount, sandbox restriction, disk full, or documents path misconfigured on a headless/Linux system where XDG documents is unset).
Common situations: Snap/Flatpak sandbox denying Documents access; corporate-locked home directory; running with a restricted user; broken ELECTRON_USER_DATA_DIR override; disk-full condition.
Related errors
- Unable to load custom CA certificate: ${(err as Error).messa
- Failed to export ${environmentType} environments.
- Failed to process ${parsedFile.fileName}: ${err.message}
- Failed to parse the file – ensure it is valid JSON or YAML
- No files selected
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/1eab91c7093913d2.
Report an issue: GitHub.