Skip to content

Commit a4fcc1c

Browse files
authored
fix windows bug (#26)
* fix windows bug * test windows * address feedback
1 parent 5740370 commit a4fcc1c

3 files changed

Lines changed: 89 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,75 @@ jobs:
8383
8484
- name: Build release binary
8585
run: cargo build --release --manifest-path cli/Cargo.toml --target ${{ matrix.target }}
86+
87+
- name: Run Rust tests
88+
run: cargo test --manifest-path cli/Cargo.toml --target ${{ matrix.target }}
89+
90+
windows-integration:
91+
name: Windows Integration Test
92+
runs-on: windows-latest
93+
needs: rust
94+
95+
steps:
96+
- name: Checkout repository
97+
uses: actions/checkout@v4
98+
99+
- name: Setup pnpm
100+
uses: pnpm/action-setup@v4
101+
with:
102+
version: 9
103+
104+
- name: Setup Node.js
105+
uses: actions/setup-node@v4
106+
with:
107+
node-version: 22
108+
cache: pnpm
109+
110+
- name: Setup Rust toolchain
111+
uses: dtolnay/rust-toolchain@stable
112+
with:
113+
targets: x86_64-pc-windows-msvc
114+
115+
- name: Cache Cargo dependencies
116+
uses: actions/cache@v4
117+
with:
118+
path: |
119+
~/.cargo/bin/
120+
~/.cargo/registry/index/
121+
~/.cargo/registry/cache/
122+
~/.cargo/git/db/
123+
cli/target/
124+
key: windows-cargo-x86_64-pc-windows-msvc-${{ hashFiles('cli/Cargo.lock') }}
125+
restore-keys: |
126+
windows-cargo-x86_64-pc-windows-msvc-
127+
128+
- name: Build Rust CLI
129+
run: cargo build --release --manifest-path cli/Cargo.toml --target x86_64-pc-windows-msvc
130+
131+
- name: Install npm dependencies
132+
run: pnpm install
133+
134+
- name: Build TypeScript
135+
run: pnpm build
136+
137+
- name: Copy CLI binary to bin directory
138+
run: |
139+
Copy-Item cli/target/x86_64-pc-windows-msvc/release/agent-browser.exe bin/agent-browser-win32-x64.exe
140+
141+
- name: Test agent-browser install command
142+
run: |
143+
$env:PATH = "$pwd\bin;$env:PATH"
144+
bin/agent-browser-win32-x64.exe install
145+
shell: pwsh
146+
147+
- name: Verify Chromium was installed
148+
run: |
149+
$playwrightPath = "$env:LOCALAPPDATA\ms-playwright"
150+
if (Test-Path $playwrightPath) {
151+
Write-Host "Playwright browsers installed at: $playwrightPath"
152+
Get-ChildItem $playwrightPath -Recurse -Depth 2 | Select-Object -First 20
153+
} else {
154+
Write-Error "Playwright browsers not found!"
155+
exit 1
156+
}
157+
shell: pwsh

cli/src/connection.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,13 @@ pub fn ensure_daemon(session: &str, headed: bool) -> Result<(), String> {
206206
{
207207
use std::os::windows::process::CommandExt;
208208

209-
let mut cmd = Command::new("node");
210-
cmd.arg(daemon_path)
209+
// On Windows, use cmd.exe to run node to ensure proper PATH resolution.
210+
// This handles cases where node.exe isn't directly in PATH but node.cmd is.
211+
// Pass the entire command as a single string to /c to handle paths with spaces.
212+
let cmd_string = format!("node \"{}\"", daemon_path.display());
213+
let mut cmd = Command::new("cmd");
214+
cmd.arg("/c")
215+
.arg(&cmd_string)
211216
.env("AGENT_BROWSER_DAEMON", "1")
212217
.env("AGENT_BROWSER_SESSION", session);
213218

cli/src/install.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ pub fn run_install(with_deps: bool) {
128128
}
129129

130130
println!("\x1b[36mInstalling Chromium browser...\x1b[0m");
131+
132+
// On Windows, we need to use cmd.exe to run npx because npx is actually npx.cmd
133+
// and Command::new() doesn't resolve .cmd files the way the shell does.
134+
// Pass the entire command as a single string to /c to handle paths with spaces.
135+
#[cfg(windows)]
136+
let status = Command::new("cmd")
137+
.args(["/c", "npx playwright install chromium"])
138+
.status();
139+
140+
#[cfg(not(windows))]
131141
let status = Command::new("npx")
132142
.args(["playwright", "install", "chromium"])
133143
.status();

0 commit comments

Comments
 (0)