{"record":{"id":"49ba6560a1483607","repo":"direnv/direnv","slug":"this-feature-is-not-supported-49ba65","errorCode":null,"errorMessage":"this feature is not supported","messagePattern":"this feature is not supported","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/shell_systemd.go","lineNumber":16,"sourceCode":"package cmd\n\nimport (\n\t\"errors\"\n\t\"strings\"\n)\n\n// systemdShell is not a real shell\ntype systemdShell struct{}\n\n// Systemd is not really a shell but is useful to add support\n// to systemd EnvironmentFile(https://0pointer.de/public/systemd-man/systemd.exec.html#EnvironmentFile=)\nvar Systemd Shell = systemdShell{}\n\nfunc (sh systemdShell) Hook() (string, error) {\n\treturn \"\", errors.New(\"this feature is not supported\")\n}\n\nfunc (sh systemdShell) Export(e ShellExport) (string, error) {\n\tvar out string\n\tfor key, value := range e {\n\t\tif value != nil {\n\t\t\tout += sh.export(key, *value)\n\t\t}\n\t}\n\treturn out, nil\n}\n\nfunc (sh systemdShell) Dump(env Env) (string, error) {\n\tvar out string\n\tfor key, value := range env {\n\t\tout += sh.export(key, value)\n\t}\n\treturn out, nil","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/direnv/direnv/blob/b00e451f547f39be7ab836d969054114a465a0f9/internal/cmd/shell_systemd.go#L1-L34","documentation":"Returned by the Hook method of systemdShell, a pseudo-shell that only renders direnv's environment diff as systemd EnvironmentFile KEY=value lines via Export/Dump. Because an EnvironmentFile is a static file consumed by systemd at unit start, there is no interactive shell session to install a prompt hook into, so Hook unconditionally returns this sentinel error. It signals an intentionally unimplemented capability of the target 'shell' format, not a runtime failure; any caller that asks systemdShell for hook code (e.g. `direnv hook systemd`) will always get it.","triggerScenarios":"Calling Hook() on direnv's Systemd shell, e.g. `direnv hook systemd` or code that resolves the systemd shell and calls Hook.","commonSituations":"Users writing systemd EnvironmentFiles use `direnv export systemd` but mistakenly try hook; automation iterates shells calling Hook on all.","solutions":["Use `direnv export systemd` to generate EnvironmentFile content; hooking is not supported","Hook only real shells (`direnv hook bash` etc.) inside a user shell, not under systemd","Filter pseudo-shells out before invoking Hook in tooling"],"exampleFix":"// before\neval \"$(direnv hook systemd)\"\n// after\n# generate EnvironmentFile:\ndirenv export systemd > /etc/environment.d/myapp.conf","handlingStrategy":"type-guard","validationCode":"if [ \"$1\" = \"systemd\" ]; then direnv export systemd; else eval \"$(direnv hook \"$1\")\"; fi","typeGuard":"func supportsHook(s cmd.Shell) bool {\n    switch s.(type) {\n    case cmd.Systemd, cmd.GzEnv, cmd.JSON, cmd.Vim:\n        return false\n    }\n    return true\n}","tryCatchPattern":null,"preventionTips":["Use `direnv export systemd` to emit EnvironmentFile content","Hook only real shells in interactive contexts","Exclude pseudo-shells from Hook iteration in tooling"],"tags":["direnv","unsupported-operation","shell-hook"],"backgroundTag":"unsupported-operation","analyzedSha":"b00e451f547f39be7ab836d969054114a465a0f9","analyzedAt":"2026-09-05T21:39:49.983Z","contentChangedAt":"2026-09-05T21:39:49.983Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}