usebruno/bruno · error · Error

Workspace path is required

Error message

Workspace path is required

What it means

The IPC handler `renderer:save-workspace-dotenv-variables` writes a .env file inside a workspace and requires a `workspacePath`. If the renderer invokes the channel without one (undefined/empty) this throws before any filesystem access.

Source

Thrown at packages/bruno-electron/src/ipc/global-environments.js:167

      const activeGlobalEnvironmentUid = workspacePath
        ? await migrateActiveGlobalEnvironmentUid(workspacePath)
        : globalEnvironmentsStore.getActiveGlobalEnvironmentUid();

      return {
        globalEnvironments,
        activeGlobalEnvironmentUid
      };
    } catch (error) {
      console.error('Error in renderer:get-global-environments:', error);
      return Promise.reject(error);
    }
  });

  // Save workspace .env file variables
  ipcMain.handle('renderer:save-workspace-dotenv-variables', async (event, { workspacePath, variables, 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);
      const content = jsonToDotenv(variables);
      await writeFile(dotEnvPath, content);

      return { success: true };
    } catch (error) {
      console.error('Error saving workspace .env file:', error);
      return Promise.reject(error);
    }
  });

  // Save workspace .env file raw content

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Pass the active workspace's absolute path from the call site.
  2. Disable Save in the UI until workspacePath is truthy.
  3. Ensure the workspace store hydrates before the env panel renders.

Example fix

// before
ipcRenderer.invoke('renderer:save-workspace-dotenv-variables', { variables });
// after
ipcRenderer.invoke('renderer:save-workspace-dotenv-variables', { workspacePath, variables });
Defensive patterns

Strategy: validation

Validate before calling

const hasWorkspace = (wp) => typeof wp === 'string' && wp.trim().length > 0;
if (!hasWorkspace(workspacePath)) throw new Error('Workspace path is required');

Prevention

When it happens

Trigger: Renderer calls `invoke('renderer:save-workspace-dotenv-variables', { variables })` omitting workspacePath; the workspace context isn't loaded yet when save fires; a stale ref passes null.

Common situations: UI race where the env editor mounts before the workspace is selected; a refactor that drops the workspace prop; testing the handler without a fixture.

Related errors


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