{"record":{"id":"c7f02fa436de2d0e","repo":"matryer/xbar","slug":"unable-to-open-path-q","errorCode":null,"errorMessage":"unable to open path %q","messagePattern":"unable to open path %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/command_service.go","lineNumber":51,"sourceCode":"func (c *CommandService) RefreshAllPlugins() {\n\tc.OnRefresh()\n}\n\n// WindowHide hides the window.\nfunc (c *CommandService) WindowHide() {\n\tc.runtime.Window.Hide()\n}\n\n// WindowMinimise minimises the window.\nfunc (c *CommandService) WindowMinimise() {\n\tc.runtime.Window.Minimise()\n}\n\n// OpenPath opens a window.\nfunc (c CommandService) OpenPath(path string) error {\n\terr := c.runCommand(\"open\", path)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"unable to open path %q\", path)\n\t}\n\treturn nil\n}\n\n// OpenURL opens a window.\nfunc (c CommandService) OpenURL(url string) error {\n\terr := c.runCommand(\"open\", url)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"unable to open URL %s\", url)\n\t}\n\treturn nil\n}\n\n// OpenFile opens a file for editing.\nfunc (c CommandService) OpenFile(path string) error {\n\terr := c.runCommand(\"open\", filepath.Join(pluginDirectory, path))\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to open %q\", path)","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/app/command_service.go#L33-L69","documentation":"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).","triggerScenarios":"Calling CommandService.OpenPath with a path that does not exist, is not a directory, or when the `open` command itself fails on the platform.","commonSituations":"Plugins folder was deleted or moved; running on a system where `open` is unavailable; passing a file where a directory is expected.","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)"],"exampleFix":"// before\nsvc.OpenPath(maybeMissingDir)\n// after\nif _, err := os.Stat(maybeMissingDir); err != nil {\n    os.MkdirAll(maybeMissingDir, 0o755)\n}\nsvc.OpenPath(maybeMissingDir)","handlingStrategy":"validation","validationCode":"// before OpenPath: ensure the path exists and is a directory\ninfo, err := os.Stat(path)\nif err != nil {\n    return fmt.Errorf(\"path %q does not exist\", path)\n}\nif !info.IsDir() {\n    return fmt.Errorf(\"path %q is not a directory\", path)\n}","typeGuard":null,"tryCatchPattern":"// Go\nif err := svc.OpenPath(dir); err != nil {\n    if strings.Contains(err.Error(), \"unable to open path\") {\n        return fmt.Errorf(\"could not open %q: %w\", dir, err)\n    }\n    return err\n}","preventionTips":["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)"],"tags":["filesystem","command-execution","macos"],"backgroundTag":"file-not-found","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}