π OpenHands: AI-Driven Development
Fix Windows dev script startup (#199)
Graham Neubigffd19e977f36
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex e1a5e0a225..3ade464954 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -15,19 +15,33 @@ permissions:jobs:test-and-build:- runs-on: ubuntu-24.04+ name: Test and build (${{ matrix.os }})+ runs-on: ${{ matrix.os }}timeout-minutes: 20+ strategy:+ fail-fast: false+ matrix:+ os:+ - ubuntu-24.04+ - windows-2025steps:- name: Check out repositoryuses: actions/checkout@v6- - name: Set up Node.js+ - name: Set up Node.js with npm cache+ if: runner.os != 'Windows'uses: actions/setup-node@v6with:node-version: 22.12.0cache: npm+ - name: Set up Node.js+ if: runner.os == 'Windows'+ uses: actions/setup-node@v6+ with:+ node-version: 22.12.0+- name: Install dependenciesrun: npm cidiff --git a/scripts/dev-static.mjs b/scripts/dev-static.mjsindex c00cd33ac8..9badbdfe17 100644--- a/scripts/dev-static.mjs+++ b/scripts/dev-static.mjs@@ -1,4 +1,3 @@-#!/usr/bin/env node/*** Static-frontend Development Stack*@@ -37,10 +36,10 @@* - OH_SECRET_KEY: Session secret key*/-import { spawn, spawnSync, execSync } from "node:child_process";+import { spawn, spawnSync } from "node:child_process";import { existsSync } from "node:fs";import { join, resolve, dirname } from "node:path";-import { fileURLToPath } from "node:url";+import { fileURLToPath, pathToFileURL } from "node:url";import { setTimeout as delay } from "node:timers/promises";import process from "node:process";@@ -178,12 +177,12 @@ NOTES:// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββfunction commandExists(cmd) {- try {- execSync(`command -v ${cmd}`, { stdio: "pipe" });- return true;- } catch {- return false;- }+ const result =+ process.platform === "win32"+ ? spawnSync("where.exe", [cmd], { stdio: "pipe" })+ : spawnSync("sh", ["-c", `command -v ${cmd}`], { stdio: "pipe" });++ return result.status === 0;}function checkPrerequisites() {@@ -653,7 +652,8 @@ export { buildFrontend, startStaticServer };// Main entry point (only when run directly, not when imported)// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-const isMainModule = import.meta.url === `file://${process.argv[1]}`;+const isMainModule =+ process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href;if (isMainModule) {main().catch((err) => {diff --git a/scripts/dev-with-automation.mjs b/scripts/dev-with-automation.mjsindex f5ac0a5f73..698fa113e9 100644--- a/scripts/dev-with-automation.mjs+++ b/scripts/dev-with-automation.mjs@@ -1,4 +1,3 @@-#!/usr/bin/env node/*** Development Stack with Automation Service*@@ -38,10 +37,10 @@* as OPENHANDS_AUTOMATION_API_KEY, making it available to agents in conversations.*/-import { spawn, execSync } from "node:child_process";+import { spawn, spawnSync } from "node:child_process";import { mkdirSync } from "node:fs";import { join, resolve, dirname } from "node:path";-import { fileURLToPath } from "node:url";+import { fileURLToPath, pathToFileURL } from "node:url";import { homedir } from "node:os";import { setTimeout as delay } from "node:timers/promises";import process from "node:process";@@ -271,12 +270,12 @@ function buildConfig(args, env = process.env) {// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββfunction commandExists(cmd) {- try {- execSync(`command -v ${cmd}`, { stdio: "pipe" });- return true;- } catch {- return false;- }+ const result =+ process.platform === "win32"+ ? spawnSync("where.exe", [cmd], { stdio: "pipe" })+ : spawnSync("sh", ["-c", `command -v ${cmd}`], { stdio: "pipe" });++ return result.status === 0;}function checkPrerequisites() {@@ -717,7 +716,8 @@ export {// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Check if this module is the main entry point-const isMainModule = import.meta.url === `file://${process.argv[1]}`;+const isMainModule =+ process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href;if (isMainModule) {main().catch((err) => {diff --git a/scripts/static-server.mjs b/scripts/static-server.mjsindex 1fe8d29a79..66a1b86e52 100644--- a/scripts/static-server.mjs+++ b/scripts/static-server.mjs@@ -1,4 +1,3 @@-#!/usr/bin/env node/*** Combined static file server + reverse proxy.*@@ -32,6 +31,7 @@ import { createReadStream } from "node:fs";import { stat } from "node:fs/promises";import { extname, normalize, resolve } from "node:path";import process from "node:process";+import { pathToFileURL } from "node:url";// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// MIME types@@ -408,7 +408,8 @@ export function startStaticServer(config) {// Main// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ-const isMainModule = import.meta.url === `file://${process.argv[1]}`;+const isMainModule =+ process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href;if (isMainModule) {try {