kovidgoyal/kitty · error
The env directive must not be empty
Error message
The env directive must not be empty
What it means
ParseEnvInstruction parses an env VAR=value or copy/delete directive; after building the EnvInstruction it verifies that the key is non-empty. An empty directive (or one that reduces to an empty variable name) triggers this error.
Source
Thrown at kittens/ssh/config.go:163
}
func ParseEnvInstruction(spec string) (ans []*EnvInstruction, err error) {
const COPY_FROM_LOCAL string = "_kitty_copy_env_var_"
ei := &EnvInstruction{}
found := false
ei.key, ei.val, found = strings.Cut(spec, "=")
ei.key = strings.TrimSpace(ei.key)
if found {
ei.val = strings.TrimSpace(ei.val)
if ei.val == COPY_FROM_LOCAL {
ei.val = ""
ei.copy_from_local = true
}
} else {
ei.delete_on_remote = true
}
if ei.key == "" {
err = fmt.Errorf("The env directive must not be empty")
}
ans = []*EnvInstruction{ei}
return
}
var paths_ctx *paths.Ctx
func resolve_file_spec(spec string, is_glob bool) ([]string, error) {
if paths_ctx == nil {
paths_ctx = &paths.Ctx{}
}
ans := os.ExpandEnv(paths_ctx.ExpandHome(spec))
if !filepath.IsAbs(ans) {
ans = paths_ctx.AbspathFromHome(ans)
}
if is_glob {
files, err := doublestar.FilepathGlob(ans)
if err != nil {View on GitHub (pinned to 6d5d0c4406)
Solutions
- Remove empty entries from the env list
- Guard generators: skip env entries where strings.TrimSpace(entry) == ""
- Validate the variable name is present before the '='
Example fix
// before env: ["PATH=/usr/bin", ""] // after env: ["PATH=/usr/bin"]
Defensive patterns
Strategy: validation
Validate before calling
entries := slices.DeleteFunc(entries, func(e string) bool { return strings.TrimSpace(e) == "" }) Type guard
func isNonEmptyEnvEntry(e string) bool { return strings.TrimSpace(e) != "" && strings.SplitN(e, "=", 2)[0] != "" } Prevention
- Filter empty entries when generating env lists
- Validate VAR names exist before '='
When it happens
Trigger: Passing 'env ' with an empty string, a directive like '=' with no variable name, or whitespace-only content after the env keyword.
Common situations: Trailing empty env entries from templating/loops generating config lines, or trailing whitespace creating an empty final entry after splitting.
Related errors
- Unsupported secret backend %s for %s. Supported backends: te
- No secret backend specified for: %s
- %s does not exist
- The value {x} is not a known choice
- The value {val} is not a valid choice for progress_bar
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/c7859332b8297522.
Report an issue: GitHub.