direnv/direnv · error
this feature is not supported
Error message
this feature is not supported
What it means
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.
Source
Thrown at internal/cmd/shell_systemd.go:16
package cmd
import (
"errors"
"strings"
)
// systemdShell is not a real shell
type systemdShell struct{}
// Systemd is not really a shell but is useful to add support
// to systemd EnvironmentFile(https://0pointer.de/public/systemd-man/systemd.exec.html#EnvironmentFile=)
var Systemd Shell = systemdShell{}
func (sh systemdShell) Hook() (string, error) {
return "", errors.New("this feature is not supported")
}
func (sh systemdShell) Export(e ShellExport) (string, error) {
var out string
for key, value := range e {
if value != nil {
out += sh.export(key, *value)
}
}
return out, nil
}
func (sh systemdShell) Dump(env Env) (string, error) {
var out string
for key, value := range env {
out += sh.export(key, value)
}
return out, nilView on GitHub (pinned to b00e451f54)
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
Example fix
// before eval "$(direnv hook systemd)" // after # generate EnvironmentFile: direnv export systemd > /etc/environment.d/myapp.conf
Defensive patterns
Strategy: type-guard
Validate before calling
if [ "$1" = "systemd" ]; then direnv export systemd; else eval "$(direnv hook "$1")"; fi
Type guard
func supportsHook(s cmd.Shell) bool {
switch s.(type) {
case cmd.Systemd, cmd.GzEnv, cmd.JSON, cmd.Vim:
return false
}
return true
} Prevention
- Use `direnv export systemd` to emit EnvironmentFile content
- Hook only real shells in interactive contexts
- Exclude pseudo-shells from Hook iteration in tooling
When it happens
Trigger: Calling Hook() on direnv's Systemd shell, e.g. `direnv hook systemd` or code that resolves the systemd shell and calls Hook.
Common situations: Users writing systemd EnvironmentFiles use `direnv export systemd` but mistakenly try hook; automation iterates shells calling Hook on all.
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/49ba6560a1483607.
Report an issue: GitHub.