{"record":{"id":"a94392eff974a517","repo":"anomalyco/sst","slug":"panic-err-a94392","errorCode":null,"errorMessage":"panic(err)","messagePattern":"panic\\(err\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/global/global.go","lineNumber":24,"sourceCode":"\n\t\"github.com/pulumi/pulumi/sdk/v3\"\n\t\"github.com/sst/sst/v3/pkg/flag\"\n)\n\nvar PULUMI_VERSION = \"v\" + sdk.Version.String()\nvar BUN_VERSION = func() string {\n\tif flag.SST_BUN_VERSION != \"\" {\n\t\treturn flag.SST_BUN_VERSION\n\t}\n\treturn \"1.2.1\"\n}()\n\nconst UV_VERSION = \"0.3.2\"\n\nvar configDir = (func() string {\n\thome, err := os.UserConfigDir()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tresult := filepath.Join(home, \"sst\")\n\tos.MkdirAll(result, 0755)\n\tos.MkdirAll(filepath.Join(result, \"bin\"), 0755)\n\treturn result\n}())\n\nfunc ConfigDir() string {\n\treturn configDir\n}\n\nfunc BinPath() string {\n\treturn filepath.Join(configDir, \"bin\")\n}\n\nfunc CertPath() string {\n\treturn filepath.Join(configDir, \"cert\")\n}","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/global/global.go#L6-L42","documentation":"The SST CLI resolves its global config directory at package init time by calling os.UserConfigDir(). On Unix this requires either $XDG_CONFIG_HOME or $HOME to be set; on Windows it requires %AppData%. If none can be determined, Go returns an error and the package panics immediately at startup (var initializer), before any SST command runs.","triggerScenarios":"Running any sst CLI command in an environment where os.UserConfigDir() fails: $HOME and $XDG_CONFIG_HOME both unset/empty (Linux/macOS), or %AppData% unset (Windows) — e.g. bare Docker containers, cron/systemd jobs, CI runners, or `sudo -i` with a scrubbed environment.","commonSituations":"Docker images based on scratch/alpine without HOME set; CI jobs running as a service user with no home directory; cron entries lacking the user environment; SSH-ing with `ssh host command` where HOME is not populated.","solutions":["Set HOME (or XDG_CONFIG_HOME on Unix) to a writable directory before running the sst CLI, e.g. `export HOME=/root` or `export XDG_CONFIG_HOME=/tmp/.config`","In Docker, add `ENV HOME=/root` (and `RUN mkdir -p /root/.config`) to the image","For cron/systemd, pass `Environment=HOME=/home/USER` or wrap the command in a login shell (`bash -lc 'sst deploy'`)","On Windows, ensure the AppData environment variable is defined for the process context running sst"],"exampleFix":"// before (Dockerfile)\nFROM alpine\nCMD [\"sst\", \"deploy\"]\n// after\nFROM alpine\nENV HOME=/root XDG_CONFIG_HOME=/root/.config\nRUN mkdir -p /root/.config\nCMD [\"sst\", \"deploy\"]","handlingStrategy":"validation","validationCode":"if [ -z \"${HOME:-}\" ] && [ -z \"${XDG_CONFIG_HOME:-}\" ]; then echo 'HOME or XDG_CONFIG_HOME must be set for sst'; exit 1; fi","typeGuard":null,"tryCatchPattern":"// Go callers importing pkg/global cannot catch an init-time panic; validate env before exec'ing sst:\nif os.Getenv(\"HOME\") == \"\" && os.Getenv(\"XDG_CONFIG_HOME\") == \"\" && os.Getenv(\"AppData\") == \"\" {\n    return fmt.Errorf(\"cannot run sst: HOME/XDG_CONFIG_HOME/AppData not set\")\n}","preventionTips":["Always set HOME (or XDG_CONFIG_HOME) in Dockerfiles, cron, and systemd units that run sst","Add a startup env check script wrapper around sst in CI","Use `ssh -t` or login shells so remote invocations inherit a home environment","Prefer explicit XDG_CONFIG_HOME pointing at a writable, persistent volume"],"tags":["go","panic","environment","init-time"],"backgroundTag":"missing-env-var","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}