@@ -4,7 +4,7 @@ import { existsSync, mkdirSync, rmSync } from "node:fs"
44import * as http from "node:http"
55import { createServer } from "node:net"
66import { homedir , tmpdir } from "node:os"
7- import { join } from "node:path"
7+ import { dirname , join } from "node:path"
88import { getCACertificates , setDefaultCACertificates } from "node:tls"
99import type { Event } from "electron"
1010import { app , BrowserWindow } from "electron"
@@ -164,7 +164,13 @@ const main = Effect.gen(function* () {
164164 return
165165 }
166166
167- preferAppEnv ( app . getPath ( "userData" ) )
167+ const dataPath = app . isPackaged
168+ ? join ( dirname ( app . getPath ( "exe" ) ) , "data" )
169+ : app . getPath ( "userData" )
170+ if ( app . isPackaged && ! existsSync ( dataPath ) ) {
171+ mkdirSync ( dataPath , { recursive : true } )
172+ }
173+ preferAppEnv ( dataPath )
168174
169175 app . on ( "second-instance" , ( _event : Event , argv : string [ ] ) => {
170176 const urls = argv . filter ( ( arg : string ) => arg . startsWith ( "opencode://" ) )
@@ -303,7 +309,7 @@ const main = Effect.gen(function* () {
303309 } ,
304310 {
305311 needsMigration,
306- userDataPath : app . getPath ( "userData" ) ,
312+ userDataPath : dataPath ,
307313 onSqliteProgress : ( progress ) => initEmitter . emit ( "sqlite" , progress ) ,
308314 onStdout : ( message ) => logger . log ( "sidecar stdout" , { message } ) ,
309315 onStderr : ( message ) => logger . warn ( "sidecar stderr" , { message } ) ,
0 commit comments