ClawX windows path robustness (#171)
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Haze <hazeone@users.noreply.github.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import { spawn } from 'child_process';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { app, shell } from 'electron';
|
||||
import { getOpenClawConfigDir, ensureDir, getClawHubCliBinPath, getClawHubCliEntryPath } from '../utils/paths';
|
||||
import { getOpenClawConfigDir, ensureDir, getClawHubCliBinPath, getClawHubCliEntryPath, quoteForCmd } from '../utils/paths';
|
||||
|
||||
export interface ClawHubSearchParams {
|
||||
query: string;
|
||||
@@ -87,17 +87,20 @@ export class ClawHubService {
|
||||
console.log(`Running ClawHub command: ${displayCommand}`);
|
||||
|
||||
const isWin = process.platform === 'win32';
|
||||
const useShell = isWin && !this.useNodeRunner;
|
||||
const env = {
|
||||
...process.env,
|
||||
CI: 'true',
|
||||
FORCE_COLOR: '0', // Disable colors for easier parsing
|
||||
FORCE_COLOR: '0',
|
||||
};
|
||||
if (this.useNodeRunner) {
|
||||
env.ELECTRON_RUN_AS_NODE = '1';
|
||||
}
|
||||
const child = spawn(this.cliPath, commandArgs, {
|
||||
const spawnCmd = useShell ? quoteForCmd(this.cliPath) : this.cliPath;
|
||||
const spawnArgs = useShell ? commandArgs.map(a => quoteForCmd(a)) : commandArgs;
|
||||
const child = spawn(spawnCmd, spawnArgs, {
|
||||
cwd: this.workDir,
|
||||
shell: isWin && !this.useNodeRunner,
|
||||
shell: useShell,
|
||||
env: {
|
||||
...env,
|
||||
CLAWHUB_WORKDIR: this.workDir,
|
||||
|
||||
@@ -13,7 +13,8 @@ import {
|
||||
getOpenClawDir,
|
||||
getOpenClawEntryPath,
|
||||
isOpenClawBuilt,
|
||||
isOpenClawPresent
|
||||
isOpenClawPresent,
|
||||
quoteForCmd,
|
||||
} from '../utils/paths';
|
||||
import { getSetting } from '../utils/store';
|
||||
import { getApiKey, getDefaultProvider, getProvider } from '../utils/secure-storage';
|
||||
@@ -755,11 +756,15 @@ export class GatewayManager extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
this.process = spawn(command, args, {
|
||||
const useShell = !app.isPackaged && process.platform === 'win32';
|
||||
const spawnCmd = useShell ? quoteForCmd(command) : command;
|
||||
const spawnArgs = useShell ? args.map(a => quoteForCmd(a)) : args;
|
||||
|
||||
this.process = spawn(spawnCmd, spawnArgs, {
|
||||
cwd: openclawDir,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
detached: false,
|
||||
shell: !app.isPackaged && process.platform === 'win32', // shell only in dev on Windows
|
||||
shell: useShell,
|
||||
env: spawnEnv,
|
||||
});
|
||||
const child = this.process;
|
||||
|
||||
Reference in New Issue
Block a user