matryer/xbar · error
load default vars
Error message
load default vars
What it means
loadVariables (pkg/plugins/variables.go:84-85) wraps errors from loadVariablesFromPluginMetadata (run in a goroutine) with 'load default vars'. It means the plugin's own source file could not be read or its metadata parsed, so default variable values cannot be established. Reported as 'load default vars: open plugin source: ...' or '... metadata.Parse: ...'.
Source
Thrown at pkg/plugins/variables.go:85
}
func (p *Plugin) loadVariables() (map[string]interface{}, error) {
var wg sync.WaitGroup
var defaultVars, jsonFileVars map[string]interface{}
var defaultVarsErr, jsonFileVarsErr error
wg.Add(1)
go func() {
defaultVars, defaultVarsErr = p.loadVariablesFromPluginMetadata()
wg.Done()
}()
wg.Add(1)
go func() {
jsonFileVars, jsonFileVarsErr = p.loadVariablesFromJSONFile()
wg.Done()
}()
wg.Wait()
if defaultVarsErr != nil {
return nil, errors.Wrap(defaultVarsErr, "load default vars")
}
if jsonFileVarsErr != nil {
return nil, errors.Wrap(jsonFileVarsErr, "load json file vars")
}
// add the json file vars to the defaults,
// and return them.
for k, v := range jsonFileVars {
defaultVars[k] = v
}
return defaultVars, nil
}
// loadVariablesFromJSONFile gets a list of environment variable friendly
// key=value pairs.
func (p *Plugin) loadVariablesFromJSONFile() (map[string]interface{}, error) {
variablesJSONFilename := p.Command + variableJSONFileExt
f, err := os.Open(variablesJSONFilename)
if err != nil && os.IsNotExist(err) {View on GitHub (pinned to d624239058)
Solutions
- Reinstall or restore the plugin so p.Command points to an existing readable file.
- Check the plugin source's `<xbar.var>` header annotations for syntax errors and fix them.
- Use errors %+v formatting to see the full chain and identify whether it failed at open, read, or metadata.Parse.
- Re-save plugin variables from the settings UI after repairing the plugin.
Example fix
// before
if _, err := os.Stat(p.Command); err != nil {
return fmt.Errorf("plugin missing: %w", err)
}
// after — skip stale plugins gracefully
if _, err := os.Stat(p.Command); err != nil {
p.Debugf("skipping plugin %s: %v", p.CleanFilename(), err)
return nil
} Defensive patterns
Strategy: fallback
Validate before calling
if info, err := os.Stat(p.Command); err != nil {
log.Printf("default vars unavailable: plugin source missing: %v", err)
} else if !info.Mode().IsRegular() || info.Mode().Perm()&0400 == 0 {
log.Printf("plugin source not a readable regular file")
} Try / catch
vars, err := p.loadVariables()
if err != nil {
var wrappedErr error
if errors.As(err, &wrappedErr) && strings.Contains(err.Error(), "load default vars") {
log.Printf("metadata defaults failed, using saved vars only: %+v", err)
return p.loadVariablesFromJSONFile()
}
return nil, err
} Prevention
- Keep plugin executables installed at stable paths; reinstall instead of hand-moving files.
- Validate plugin metadata annotations at install time.
- Re-check plugin integrity (file exists + readable) after app updates.
- Warn users when an upgrade replaces a plugin whose vars they customized.
When it happens
Trigger: p.Command (the plugin executable path) does not exist or is unreadable; the file exceeds the 1MB read limit path fails; metadata.Parse rejects malformed `<xbar.var>` declarations in the plugin script.
Common situations: The plugin binary was deleted/updated while its .vars.json remains; user installed a plugin from an untrusted source with broken var annotations; path with spaces or moved installation directory invalidates p.Command.
Related errors
AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02).
Data as JSON: /api/errors/2625681ecb2a5b9f.
Report an issue: GitHub.