matryer/xbar · error
write default variables
Error message
write default variables
What it means
Returned by writePluginFiles when SaveVariableValues fails to persist the plugin's declared default variable values next to the installed plugin file. This happens after a successful install when the parsed plugin metadata declares vars, and the variable store cannot be written. The plugin files themselves are already installed, so the failure leaves a partially initialized plugin.
Source
Thrown at pkg/plugins/install.go:149
if f.Filename != plugin.Filename {
continue
}
if err := os.Chmod(pluginFile, 0755); err != nil {
return errors.Wrap(err, "set executable permission on plugin entry point")
}
// write the default variables
plugin, err := metadata.Parse(metadata.DebugfNoop, pluginFile, f.Content)
if err != nil {
log.Println("install plugin: unable to parse metadata:", err)
}
if len(plugin.Vars) > 0 {
defaultVars := make(map[string]interface{})
for _, pluginVar := range plugin.Vars {
defaultVars[pluginVar.Name] = pluginVar.DefaultValue()
}
err := SaveVariableValues(i.PluginDir, pluginFile, defaultVars)
if err != nil {
return errors.Wrap(err, "write default variables")
}
}
}
return nil
}
View on GitHub (pinned to d624239058)
Solutions
- Check that i.PluginDir exists and is writable by the current user (mkdir -p, chown).
- Inspect the variable store file for corruption or locks and repair/remove it.
- Re-run the install after fixing the directory; the plugin will be re-created with fresh defaults.
Example fix
// before
installer := plugins.Installer{PluginDir: "/var/lib/upterm/plugins"} // not writable by user
// after
home, _ := os.UserHomeDir()
installer := plugins.Installer{PluginDir: filepath.Join(home, ".upterm", "plugins")} Defensive patterns
Strategy: try-catch
Validate before calling
func ensurePluginDirWritable(dir string) error {
if err := os.MkdirAll(dir, 0755); err != nil { return err }
f, err := os.CreateTemp(dir, ".var-test")
if err != nil { return err }
f.Close(); os.Remove(f.Name())
return nil
} Try / catch
err := installer.Install(plugin)
if err != nil && strings.Contains(err.Error(), "write default variables") {
log.Printf("plugin installed but defaults not saved: %v", err)
// fallback: re-run SaveVariableValues after fixing PluginDir permissions
}
return err Prevention
- Keep PluginDir consistent between install and variable-save paths (same config).
- Ensure PluginDir is writable at startup; pre-create it.
- Avoid concurrent installs of the same plugin.
- Handle partial installs: on failure, remove the partially installed plugin file before retrying.
When it happens
Trigger: Installer.Install -> writePluginFiles, for entry-point files whose parsed metadata declares Vars, when SaveVariableValues(i.PluginDir, pluginFile, defaultVars) fails — typically because i.PluginDir is not writable or the plugin's own variable file is corrupt/locked.
Common situations: Read-only or quota-limited plugin directory; PluginDir configured differently between install and variable-save; concurrent installs racing on the same variable store file.
Related errors
- create directory %s for plugin
- create plugin file %s
- write plugin file %s
- set executable permission on plugin entry point
- ReadDir
AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02).
Data as JSON: /api/errors/b9dd888e0b86b873.
Report an issue: GitHub.