direnv/direnv · error
this feature is not supported
Error message
this feature is not supported
What it means
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.
Source
Thrown at internal/cmd/shell_json.go:16
package cmd
import (
"encoding/json"
"errors"
)
// jsonShell is not a real shell
type jsonShell struct{}
// JSON is not really a shell but it fits. Useful to add support to editor and
// other external tools that understand JSON as a format.
var JSON Shell = jsonShell{}
func (sh jsonShell) Hook() (string, error) {
return "", errors.New("this feature is not supported")
}
func (sh jsonShell) Export(e ShellExport) (string, error) {
out, err := json.MarshalIndent(e, "", " ")
if err != nil {
return "", err
}
return string(out), nil
}
func (sh jsonShell) Dump(env Env) (string, error) {
out, err := json.MarshalIndent(env, "", " ")
if err != nil {
return "", err
}
return string(out), nil
}
View on GitHub (pinned to b00e451f54)
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.)
Example fix
// before eval "$(direnv hook json)" // after eval "$(direnv export json)"
Defensive patterns
Strategy: type-guard
Validate before calling
if [ "$1" = "json" ]; then direnv export json; else eval "$(direnv hook "$1")"; fi
Type guard
func supportsHook(s cmd.Shell) bool {
switch s.(type) {
case cmd.JSON, cmd.GzEnv, cmd.Systemd, cmd.Vim:
return false
}
return true
} Prevention
- 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
When it happens
Trigger: Calling Hook() on direnv's JSON shell, e.g. `direnv hook json` or code that selects the json shell and invokes Hook.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- the gzenv shell doesn't support hooking
- this feature is not supported
- this feature is not supported. Install the direnv.vim plugin
- missing PATH argument
- invalid arguments
AI-assisted analysis of direnv/direnv@b00e451f54 (2026-09-05).
Data as JSON: /api/errors/bb5c71f2ddce3890.
Report an issue: GitHub.