{"record":{"id":"f05b7dbdd4df307d","repo":"wtfutil/wtf","slug":"command-shell-not-defined-in-shell-environment-va","errorCode":null,"errorMessage":"command shell not defined in $SHELL environment variable","messagePattern":"command shell not defined in \\$SHELL environment variable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/progress/widget.go","lineNumber":18,"sourceCode":"package progress\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/charmbracelet/bubbles/progress\"\n\t\"github.com/muesli/reflow/ansi\"\n\t\"github.com/rivo/tview\"\n\t\"github.com/wtfutil/wtf/utils\"\n\t\"github.com/wtfutil/wtf/view\"\n)\n\nvar errShellUndefined = errors.New(\"command shell not defined in $SHELL environment variable\")\n\n// Widget is the container for your module's data\ntype Widget struct {\n\tview.TextWidget\n\n\tsettings *Settings\n\n\tminimum float64\n\tmaximum float64\n\tcurrent float64\n\tpercent float64\n\n\tpadding string\n\n\tshell string\n\n\terr error\n}","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/progress/widget.go#L1-L36","documentation":"The progress widget's execValueCmd runs a shell command by invoking the user's shell. It is constructed by joining the shell path (from widget.shell, sourced from $SHELL) with the command, so without a shell path the exec call cannot be built. The widget deliberately refuses to run and returns this sentinel error (errShellUndefined) instead of guessing a default shell like /bin/sh.","triggerScenarios":"Calling widget.execValueCmd(cmd) when widget.shell is an empty string. This happens when the $SHELL environment variable is unset or empty in the environment WTFUtil was launched from (e.g. started by systemd, cron, a launcher, or an IDE that strips env).","commonSituations":"WTFUtil launched via a systemd user service, desktop autostart, cron job, or IDE run configuration where $SHELL is not exported; minimal containers or CI environments without $SHELL set.","solutions":["Set the SHELL environment variable before launching WTFUtil (e.g. export SHELL=/bin/bash or SHELL=/bin/zsh wtfutil).","If launching from systemd/cron, add Environment=SHELL=/bin/bash to the unit or crontab entry.","As a workaround inside the module config, check whether the progress module allows configuring the shell via settings and set it explicitly."],"exampleFix":"// before (launch environment without SHELL)\n$ wtfutil\n// error: command shell not defined in $SHELL environment variable\n\n// after\n$ export SHELL=/bin/bash\n$ wtfutil","handlingStrategy":"validation","validationCode":"if os.Getenv(\"SHELL\") == \"\" {\n    return errors.New(\"$SHELL must be set before running wtfutil progress module\")\n}","typeGuard":null,"tryCatchPattern":"val, err := widget.execValueCmd(cmd)\nif errors.Is(err, errShellUndefined) {\n    // fall back to a default shell or skip the module\n}","preventionTips":["Always export SHELL in service/launcher environments (systemd units, cron, IDE run configs).","Check `echo $SHELL` in the exact environment that launches wtfutil.","Prefer launching wtfutil from an interactive login shell."],"tags":["shell","environment-variable","configuration"],"backgroundTag":"missing-env-var","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}