{"record":{"id":"bb5c71f2ddce3890","repo":"direnv/direnv","slug":"this-feature-is-not-supported","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_json.go","lineNumber":16,"sourceCode":"package cmd\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n)\n\n// jsonShell is not a real shell\ntype jsonShell struct{}\n\n// JSON is not really a shell but it fits. Useful to add support to editor and\n// other external tools that understand JSON as a format.\nvar JSON Shell = jsonShell{}\n\nfunc (sh jsonShell) Hook() (string, error) {\n\treturn \"\", errors.New(\"this feature is not supported\")\n}\n\nfunc (sh jsonShell) Export(e ShellExport) (string, error) {\n\tout, err := json.MarshalIndent(e, \"\", \"  \")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(out), nil\n}\n\nfunc (sh jsonShell) Dump(env Env) (string, error) {\n\tout, err := json.MarshalIndent(env, \"\", \"  \")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(out), nil\n}\n","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/direnv/direnv/blob/b00e451f547f39be7ab836d969054114a465a0f9/internal/cmd/shell_json.go#L1-L34","documentation":"The JSON 'shell' is a serialization backend (pretty-printed JSON export) for editors and external tools, not an interactive shell, so it cannot generate a hook script. Hook() on jsonShell always returns this error.","triggerScenarios":"Calling Hook() on direnv's JSON shell, e.g. `direnv hook json` or code that selects the json shell and invokes Hook.","commonSituations":"Users mistake `direnv export json` for `direnv hook json`; editor integrations that consume JSON export accidentally wire up hook; generic tooling calls Hook on every registered shell.","solutions":["Use `direnv export json` to get JSON output; only real shells support hook","Hook a real shell: `eval \"$(direnv hook bash)\"` etc.","In tooling, guard: only call Hook for shells that support it (bash, zsh, fish, tcsh, elvish, etc.)"],"exampleFix":"// before\neval \"$(direnv hook json)\"\n// after\neval \"$(direnv export json)\"","handlingStrategy":"type-guard","validationCode":"if [ \"$1\" = \"json\" ]; then direnv export json; else eval \"$(direnv hook \"$1\")\"; fi","typeGuard":"func supportsHook(s cmd.Shell) bool {\n    switch s.(type) {\n    case cmd.JSON, cmd.GzEnv, cmd.Systemd, cmd.Vim:\n        return false\n    }\n    return true\n}","tryCatchPattern":null,"preventionTips":["Use `direnv export json` for JSON output, never `direnv hook json`","Treat JSON as an export format for tools, not a shell","Filter pseudo-shells before invoking Hook in generic 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"}