matryer/xbar · error
unable to open path %q
Error message
unable to open path %q
What it means
OpenPath runs the OS `open` command on the given path to reveal it in Finder. If the underlying command fails (nonexistent path, wrong type), the error is wrapped with errors.Wrapf(err, "unable to open path %q", path).
Source
Thrown at app/command_service.go:51
func (c *CommandService) RefreshAllPlugins() {
c.OnRefresh()
}
// WindowHide hides the window.
func (c *CommandService) WindowHide() {
c.runtime.Window.Hide()
}
// WindowMinimise minimises the window.
func (c *CommandService) WindowMinimise() {
c.runtime.Window.Minimise()
}
// OpenPath opens a window.
func (c CommandService) OpenPath(path string) error {
err := c.runCommand("open", path)
if err != nil {
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)View on GitHub (pinned to d624239058)
Solutions
- Verify the path exists (os.Stat) before calling OpenPath
- Recreate the plugins directory if it was deleted
- Check the platform supports the `open` command (macOS)
Example fix
// before
svc.OpenPath(maybeMissingDir)
// after
if _, err := os.Stat(maybeMissingDir); err != nil {
os.MkdirAll(maybeMissingDir, 0o755)
}
svc.OpenPath(maybeMissingDir) Defensive patterns
Strategy: validation
Validate before calling
// before OpenPath: ensure the path exists and is a directory
info, err := os.Stat(path)
if err != nil {
return fmt.Errorf("path %q does not exist", path)
}
if !info.IsDir() {
return fmt.Errorf("path %q is not a directory", path)
} Try / catch
// Go
if err := svc.OpenPath(dir); err != nil {
if strings.Contains(err.Error(), "unable to open path") {
return fmt.Errorf("could not open %q: %w", dir, err)
}
return err
} Prevention
- Recreate the plugins directory if missing before opening it
- Use os.Stat to verify existence before opening
- Confirm the app runs on a platform where `open` exists (macOS)
When it happens
Trigger: Calling CommandService.OpenPath with a path that does not exist, is not a directory, or when the `open` command itself fails on the platform.
Common situations: Plugins folder was deleted or moved; running on a system where `open` is unavailable; passing a file where a directory is expected.
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
- failed to open %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/c7f02fa436de2d0e.
Report an issue: GitHub.