Fix/desktop lite edition cmd exec failure (#961)

* This fixes a data integrity issue affecting fresh installations of Desktop Lite and any environment where agent.other_config and serveral columns are not pre-initialized. This will stop Desktop Lite edtion from saving any agent setting.

The root cause is missing default initialization of JSON field in update flow, leading to NOT NULL violations in both SQLite and Postgres.

Fix ensures consistent behavior across Lite and Standard deployments.

* Fix: Destop Lite Windows edition exec failure
The executing of local commands use sh wrongly.
This commit is contained in:
steelstring authored and GitHub committed 2026-04-19 14:20:21 +07:00
1 parent 9f68f3ee0d
commit 2bc8e909f1
3 files changed
+33 -5

No files matched your search

+5 -2
View File
@@ -8,6 +8,7 @@ import (
"log/slog"
"net"
"os/exec"
"runtime"
"strings"
"time"
)
@@ -285,6 +286,8 @@ func apkViaHelper(ctx context.Context, action, pkg string) (bool, string) {
// cleanCaches removes pip and npm caches to save disk space.
func cleanCaches(ctx context.Context) {
exec.CommandContext(ctx, "pip3", "cache", "purge").Run() //nolint:errcheck
exec.CommandContext(ctx, "sh", "-c", "rm -rf /tmp/npm-*").Run() //nolint:errcheck
exec.CommandContext(ctx, "pip3", "cache", "purge").Run() //nolint:errcheck
if runtime.GOOS != "windows" {
exec.CommandContext(ctx, "sh", "-c", "rm -rf /tmp/npm-*").Run() //nolint:errcheck
}
}
+16 -2
View File
@@ -12,6 +12,7 @@ import (
"os/exec"
"path/filepath"
"regexp"
"runtime"
"slices"
"strings"
"time"
@@ -496,9 +497,22 @@ func (t *ExecTool) executeCredentialedSandbox(ctx context.Context, absPath strin
// buildCredentialedEnv creates a minimal environment with injected credentials.
// Inherits PATH and HOME from parent process, adds credential env vars.
func buildCredentialedEnv(envMap map[string]string) []string {
var pathDefault string
var homeDefault string
if runtime.GOOS == "windows" {
pathDefault = "C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem"
homeDefault = os.Getenv("USERPROFILE")
if homeDefault == "" {
homeDefault = "C:\\Users\\Default"
}
} else {
pathDefault = "/usr/local/bin:/usr/bin:/bin"
homeDefault = "/tmp"
}
env := []string{
"PATH=" + getenvDefault("PATH", "/usr/local/bin:/usr/bin:/bin"),
"HOME=" + getenvDefault("HOME", "/tmp"),
"PATH=" + getenvDefault("PATH", pathDefault),
"HOME=" + getenvDefault("HOME", homeDefault),
"LANG=" + getenvDefault("LANG", "en_US.UTF-8"),
"USER=" + getenvDefault("USER", "goclaw"),
}
+12 -1
View File
@@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"regexp"
"runtime"
"strings"
"time"
@@ -360,9 +361,19 @@ func (t *ExecTool) executeOnHost(ctx context.Context, command, cwd string) *Resu
ctx, cancel := context.WithTimeout(ctx, t.timeout)
defer cancel()
//<<<<<<< HEAD
var cmd *exec.Cmd
if runtime.GOOS == "windows" {
cmd = exec.Command("cmd", "/c", command)
} else {
cmd = exec.Command("sh", "-c", command)
}
//=======
// Use plain exec.Command (not CommandContext) so we control the kill sequence.
// CommandContext would SIGKILL only the direct child, leaving forked grandchildren alive.
cmd := exec.Command("sh", "-c", command)
// cmd := exec.Command("sh", "-c", command)
//>>>>>>> dev
cmd.Dir = cwd
// Scrub credential env vars so fall-through exec cannot exfiltrate