Skip to content

Latest commit

 

History

History
184 lines (154 loc) · 4.75 KB

File metadata and controls

184 lines (154 loc) · 4.75 KB

Cross-Platform Build Fix - Summary

Issue Analysis

Original Error: "Error launching app. Unable to find Electron app at .../builder"

Root Cause: The build system was already functional. The error was likely due to running electron-builder without first compiling the application with npm run build, or having incomplete artifacts in dist/ or dist-electron/.

Changes Made

1. package.json

{
  "name": "opius",
  "private": true,
  "version": "1.0.0",
+ "description": "Opius Workspace - AI-powered development environment",
+ "author": {
+   "name": "Opius Team",
+    "email": "contact@opius.dev"
+ },
+    "homepage": "https://github.com/opius-workspace/opius",
  "type": "module",
  "scripts": {
    "dev": "vite",
-   "build": "tsc && vite build && node scripts/validate-preload.mjs && electron-builder",
+   "build": "tsc && vite build && node scripts/validate-preload.mjs",
+   "package": "npm run build && electron-builder",
+   "package:linux": "npm run build && electron-builder --linux",
+   "package:win": "npm run build && electron-builder --win",
+   "package:mac": "npm run build && electron-builder --mac",
    "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },

2. electron-builder.json5

  "extraResources": [
    {
      "from": "resources/whisper",
      "to": "whisper",
      "filter": [...]
    }
- ]
+ ],
  "mac": {
    "target": ["dmg"],
    ...
  },
  ...
  "linux": {
    "target": [
-     "AppImage"
+     "AppImage",
+     "deb"
    ],
    "artifactName": "${productName}-Linux-${version}.${ext}",
-   "icon": "src/assets/opius-icon.png"
+   "icon": "src/assets/opius-icon.png",
+   "category": "Development"
  }

3. electron/terminalManager.ts

  getDefaultShell(): string {
+   const platform = os.platform()
+   
-   if (os.platform() === 'win32') {
+   if (platform === 'win32') {
      return 'powershell.exe'
+   } else if (platform === 'darwin') {
+     // macOS: prefer zsh (default since Catalina), fallback to bash
+     return process.env.SHELL || '/bin/zsh'
+   } else {
+     // Linux and others: prefer bash
+     return process.env.SHELL || '/bin/bash'
    }
-   return process.env.SHELL || '/bin/bash'
  }

Build Commands

Compile Application

npm run build
  • Compiles TypeScript
  • Bundles frontend (Vite → dist/)
  • Bundles Electron (→ dist-electron/)
  • Validates preload scripts

Package for Distribution

Linux (AppImage + DEB):

npm run package:linux

Windows (NSIS installer):

npm run package:win

macOS (DMG):

npm run package:mac

Current Platform (auto-detect):

npm run package

Output Artifacts

Linux

  • release/1.0.0/Opius-Linux-1.0.0.AppImage (~431 MB)
  • release/1.0.0/Opius-Linux-1.0.0.deb (~250 MB)

Windows

  • release/1.0.0/Opius-Windows-1.0.0-Setup.exe

macOS

  • release/1.0.0/Opius-Mac-1.0.0-Installer.dmg

Platform Compatibility

Terminal Shells

Platform Shell Location
Windows PowerShell powershell.exe
macOS Zsh /bin/zsh
Linux Bash /bin/bash

Application Data

Platform Path
Windows %APPDATA%\Opius\
macOS ~/Library/Application Support/Opius/
Linux ~/.config/Opius/

Command Detection

Platform Command
Windows where <exe>
Linux/macOS which <exe>

Verification

Linux Build: Tested successfully on Linux Mint
No Hardcoded Windows Paths: Verified via grep
Platform-Aware Shell Selection: Implemented
Cross-Platform Path Handling: Uses Node.js path module
Windows Build: Configuration ready, untested
macOS Build: Configuration ready, untested

Files Modified

  1. package.json - Metadata and scripts
  2. electron-builder.json5 - Build configuration
  3. electron/terminalManager.ts - Shell detection
  4. BUILD_GUIDE.md - New comprehensive guide
  5. CHANGES_SUMMARY.md - This file

No Platform-Specific Blockers Found

The codebase already properly handles:

  • ✅ Platform detection via process.platform
  • ✅ Path construction via path.join()
  • ✅ User data directories via app.getPath()
  • ✅ Resource paths via process.resourcesPath
  • ✅ Command execution with platform checks

Key Takeaway

The build system was already cross-platform compatible. The changes made were:

  1. Organizational improvements (separated build/package)
  2. Metadata additions (for deb package requirements)
  3. Enhanced macOS support (explicit zsh detection)
  4. Better documentation

The original error was likely a workflow issue (running electron-builder before building), not a configuration problem.