kovidgoyal/kitty · error
%s is not a valid glob pattern with error: %w
Error message
%s is not a valid glob pattern with error: %w
What it means
resolve_file_spec expands a copy-instruction file spec with doublestar.FilepathGlob when it contains glob metacharacters. If the pattern is malformed (e.g. unbalanced '['), doublestar returns an error which is wrapped with the spec.
Source
Thrown at kittens/ssh/config.go:182
}
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 {
return nil, fmt.Errorf("%s is not a valid glob pattern with error: %w", spec, err)
}
if len(files) == 0 {
return nil, fmt.Errorf("%s matches no files", spec)
}
return files, nil
}
err := unix.Access(ans, unix.R_OK)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return nil, fmt.Errorf("%s does not exist", spec)
}
return nil, fmt.Errorf("Cannot read from: %s with error: %w", spec, err)
}
return []string{ans}, nil
}
func get_arcname(loc, dest, home string) (arcname string) {
if dest != "" {View on GitHub (pinned to 6d5d0c4406)
Solutions
- Fix the glob pattern syntax (balanced brackets, valid character classes)
- Escape literal metacharacters if the filename really contains them
- Test the pattern with a glob tester before putting it in config
Example fix
// before copy: ~/logs/[2024- // after copy: ~/logs/2024-*
Defensive patterns
Strategy: validation
Validate before calling
if _, err := doublestar.FilepathGlob(pattern); err != nil { /* reject pattern before config load */ } Type guard
func isValidGlob(p string) bool { _, err := doublestar.FilepathGlob(p); return err == nil } Prevention
- Lint glob patterns in config during CI
- Escape literal brackets/asterisks in filenames
When it happens
Trigger: A copy: or env copy spec like '~/data/[a-' where the glob syntax itself is invalid.
Common situations: Windows-style paths with brackets, typos in character classes, or accidentally treating a literal filename containing '*' or '[' as a glob.
Related errors
- %s matches no files
- %s does not exist
- Unsupported secret backend %s for %s. Supported backends: te
- No secret backend specified for: %s
- The env directive must not be empty
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/71a5c43b5b6d4a03.
Report an issue: GitHub.