Skip to content

Commit 3d9b28e

Browse files
andystimeclaude
andcommitted
fix: improve Windows support and GPU discovery
1. Allow agent registration without GPU detection: - Users with AMD GPUs or no GPUs can now register agents - Registration continues with warning instead of failing - GPU configuration can be added later via dashboard 2. Fix PowerShell execution policy blocking env.ps1: - Added comprehensive usage instructions to env.ps1 - Updated install.ps1 quick start guide - Recommend eval-style activation to bypass ExecutionPolicy 3. Improve VSCode error handling on Windows: - Better detection of "command not found" errors (code 9009, 1) - Detect Chinese error messages (不是内部或外部命令) - Show friendly English error with install guide link Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent d536e73 commit 3d9b28e

4 files changed

Lines changed: 59 additions & 14 deletions

File tree

cmd/ggo/agent/agent.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,24 @@ func newRegisterCmd() *cobra.Command {
210210

211211
gpus, err := discoverGPUs()
212212
if err != nil {
213-
cmd.SilenceUsage = true
213+
// GPU discovery failed (e.g., unsupported GPU vendor like AMD, or no GPU drivers)
214+
// Log a warning but allow registration to continue with empty GPU list.
215+
// This enables users to install the agent on machines without supported GPUs
216+
// and add GPU configuration later via the dashboard.
214217
if !out.IsJSON() {
215-
out.Error(fmt.Sprintf("Failed to discover GPUs: %v", err))
218+
out.Warning(fmt.Sprintf("Failed to discover GPUs: %v", err))
219+
out.Warning("Registering agent without GPU configuration. You can configure GPUs later via the dashboard.")
216220
}
217-
return err
221+
klog.Warningf("Failed to discover GPUs, continuing registration: error=%v", err)
222+
gpus = []api.GPUInfo{} // Empty GPU list
218223
}
219-
if len(gpus) == 0 {
220-
cmd.SilenceUsage = true
224+
if len(gpus) == 0 && err == nil {
225+
// No error but no GPUs found - warn but allow registration
221226
if !out.IsJSON() {
222-
out.Error("No GPUs found. Please check your GPU configuration or use GPU_GO_MOCK_GPUS for testing")
227+
out.Warning("No GPUs found. Registering agent without GPU configuration.")
228+
out.Info("Tip: Use GPU_GO_MOCK_GPUS=1 for testing, or configure GPUs via the dashboard.")
223229
}
224-
return fmt.Errorf("no GPUs found")
230+
klog.Warningf("No GPUs discovered, continuing registration with empty GPU list")
225231
}
226232

227233
agentInstance := agent.NewAgent(client, configMgr)

internal/studio/env.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,20 @@ func GeneratePowerShellScript(config *GPUEnvConfig, paths *platform.Paths) (stri
416416
script.WriteString("# GPU Go environment setup script (PowerShell)\n")
417417
script.WriteString("# Generated by ggo use\n")
418418
script.WriteString("#\n")
419+
script.WriteString("# USAGE:\n")
420+
script.WriteString("# If you get an ExecutionPolicy error when running this script,\n")
421+
script.WriteString("# use one of these methods instead:\n")
422+
script.WriteString("#\n")
423+
script.WriteString("# Method 1 (Recommended): Use eval-style activation\n")
424+
script.WriteString("# ggo use <share-link> -y | Out-String | Invoke-Expression\n")
425+
script.WriteString("#\n")
426+
script.WriteString("# Method 2: Bypass execution policy for this script\n")
427+
script.WriteString("# powershell -ExecutionPolicy Bypass -File env.ps1\n")
428+
script.WriteString("#\n")
429+
script.WriteString("# Method 3: Unblock the file (requires admin)\n")
430+
script.WriteString("# Unblock-File -Path env.ps1\n")
431+
script.WriteString("# . .\\env.ps1\n")
432+
script.WriteString("#\n")
419433
script.WriteString("# IMPORTANT: Windows DLL loading note\n")
420434
script.WriteString("# Setting PATH helps but System32 DLLs still take priority.\n")
421435
script.WriteString("# For reliable GPU library loading, use: ggo launch <program>\n")

scripts/install.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ function Install-Ggo {
414414
Write-Host " # Register as agent (on GPU server)" -ForegroundColor Gray
415415
Write-Host " ggo agent register --token <your-token>" -ForegroundColor White
416416
Write-Host ""
417-
Write-Host " # Use a shared GPU" -ForegroundColor Gray
418-
Write-Host " ggo use <short-link>" -ForegroundColor White
417+
Write-Host " # Use a shared GPU (PowerShell)" -ForegroundColor Gray
418+
Write-Host " ggo use <short-link> -y | Out-String | Invoke-Expression" -ForegroundColor White
419419
Write-Host ""
420420
}
421421
finally {

vscode-extension/src/cli/cli.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,29 +332,54 @@ export class CLI {
332332
let stderr = '';
333333

334334
child.stdout.on('data', (data: Buffer) => {
335-
stdout += data.toString();
335+
// On Windows, try to decode using the correct encoding
336+
// Node.js Buffer.toString() defaults to UTF-8, but Windows CMD outputs in the system codepage (e.g., GBK for Chinese Windows)
337+
if (process.platform === 'win32') {
338+
// For Windows, we use UTF-8 as modern Windows shells should support it
339+
// If there are encoding issues, the user should ensure their terminal uses UTF-8
340+
stdout += data.toString('utf8');
341+
} else {
342+
stdout += data.toString();
343+
}
336344
});
337345

338346
child.stderr.on('data', (data: Buffer) => {
339-
stderr += data.toString();
347+
if (process.platform === 'win32') {
348+
stderr += data.toString('utf8');
349+
} else {
350+
stderr += data.toString();
351+
}
340352
});
341353

342354
child.on('close', (code) => {
343355
if (code === 0) {
344356
Logger.log(`Command success: ${args[0]}`);
345357
resolve(stdout);
346358
} else {
347-
const msg = stderr || `Command failed with code ${code}`;
359+
let msg = stderr || `Command failed with code ${code}`;
348360
Logger.error(`Command failed (code ${code}):`, msg);
349361

350362
// Special handling for CLI not found
351-
if (code === 127) {
363+
// On Unix: code 127, On Windows: code 1 or 9009 with specific error patterns
364+
const isCliNotFound = code === 127 ||
365+
code === 9009 ||
366+
(process.platform === 'win32' && code === 1 && (
367+
stderr.includes('is not recognized') ||
368+
stderr.includes('不是内部或外部命令') ||
369+
stderr.includes('not found')
370+
));
371+
372+
if (isCliNotFound) {
373+
msg = `GPUGo CLI not found at '${cliPath}'. Please ensure ggo.exe is installed and in your PATH, or configure the path in settings.`;
352374
vscode.window.showErrorMessage(
353-
`GPUGo CLI not found at '${cliPath}'. Please check your settings.`,
375+
msg,
376+
'Install Guide',
354377
'Settings'
355378
).then(s => {
356379
if (s === 'Settings') {
357380
vscode.commands.executeCommand('workbench.action.openSettings', 'gpugo.cliPath');
381+
} else if (s === 'Install Guide') {
382+
vscode.env.openExternal(vscode.Uri.parse('https://go.gpu.tf/docs'));
358383
}
359384
});
360385
}

0 commit comments

Comments
 (0)