matryer/xbar · error
failed to open %q
Error message
failed to open %q
What it means
OpenFile runs `open` on filepath.Join(pluginDirectory, path) so users can edit a plugin file. Failure of the command (or of opening the resulting path) is wrapped with errors.Wrapf(err, "failed to open %q", path).
Source
Thrown at app/command_service.go:69
return errors.Wrapf(err, "unable to open path %q", path)
}
return nil
}
// OpenURL opens a window.
func (c CommandService) OpenURL(url string) error {
err := c.runCommand("open", url)
if err != nil {
return errors.Wrapf(err, "unable to open URL %s", url)
}
return nil
}
// OpenFile opens a file for editing.
func (c CommandService) OpenFile(path string) error {
err := c.runCommand("open", filepath.Join(pluginDirectory, path))
if err != nil {
return errors.Wrapf(err, "failed to open %q", path)
}
return nil
}
// runCommand runs the command, wiring up stdout and stderr, and
// inheriting the environment.
func (CommandService) runCommand(name string, args ...string) error {
cmd := exec.Command(name, args...)
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
}
cmd.Env = os.Environ()
return cmd.Run()
}
View on GitHub (pinned to d624239058)
Solutions
- Verify the file exists at filepath.Join(pluginDirectory, path) before calling OpenFile
- Pass the plugin-relative name exactly as listed in the plugins directory
- Check a default application is associated with the file type
Example fix
// before
svc.OpenFile("removed-plugin.5m.py") // file no longer exists
// after
p := filepath.Join(pluginDirectory, name)
if _, err := os.Stat(p); err == nil {
svc.OpenFile(name)
} Defensive patterns
Strategy: validation
Validate before calling
// before OpenFile: verify the joined path exists
target := filepath.Join(pluginDirectory, relPath)
if _, err := os.Stat(target); err != nil {
return fmt.Errorf("plugin file %q not found", relPath)
} Try / catch
// Go
if err := svc.OpenFile(relPath); err != nil {
if strings.Contains(err.Error(), "failed to open") {
return fmt.Errorf("cannot edit plugin %q: %w", relPath, err)
}
return err
} Prevention
- Pass plugin-relative paths exactly as they appear in the plugins directory
- Refresh the plugin list after installs/uninstalls so menu entries stay valid
- Remember OpenFile joins with pluginDirectory — don't pass absolute paths
When it happens
Trigger: Calling CommandService.OpenFile with a plugin-relative path that does not exist under pluginDirectory, or when the `open` command fails to launch the default editor.
Common situations: Plugin was uninstalled/renamed but its menu entry still requests OpenFile; passing an absolute path that gets joined incorrectly onto pluginDirectory; no default application for the file type.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- unable to open path %q
- unable to open URL %s
- create directory %s for plugin
- create plugin file %s
- write plugin file %s
AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02).
Data as JSON: /api/errors/5b01bbd8b2a9fe4b.
Report an issue: GitHub.