From 4656203e4de444cbe369b7456b115cdfae387f4d Mon Sep 17 00:00:00 2001 From: zlm Date: Wed, 10 Jun 2026 12:21:52 +0800 Subject: [PATCH] fix: use shell=True on Windows for npx.cmd --- desktop/tray.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/desktop/tray.py b/desktop/tray.py index 25c6e94..8f5a136 100644 --- a/desktop/tray.py +++ b/desktop/tray.py @@ -35,22 +35,25 @@ def start_backend(): env['PORT'] = '3000' env['SKIP_PLC'] = '1' - # Use npx to run tsx, regardless of OS - cmd = ['npx', 'tsx', 'src/index.ts'] - - # Windows: hide console window - extra = {} if sys.platform == 'win32': - extra['creationflags'] = 0x08000000 # CREATE_NO_WINDOW - - backend = subprocess.Popen( - cmd, - cwd=str(PROJECT_DIR), - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - env=env, - **extra, - ) + # Windows: npx.cmd needs shell=True; hide console + backend = subprocess.Popen( + 'npx tsx src/index.ts', + cwd=str(PROJECT_DIR), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + env=env, + shell=True, + creationflags=0x08000000, + ) + else: + backend = subprocess.Popen( + ['npx', 'tsx', 'src/index.ts'], + cwd=str(PROJECT_DIR), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + env=env, + ) # Read stdout/stderr in background for log window def read_stream(stream, prefix=''):