{"record":{"id":"5b01bbd8b2a9fe4b","repo":"matryer/xbar","slug":"failed-to-open-q","errorCode":null,"errorMessage":"failed to open %q","messagePattern":"failed to open %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/command_service.go","lineNumber":69,"sourceCode":"\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)\n\t}\n\treturn nil\n}\n\n// runCommand runs the command, wiring up stdout and stderr, and\n// inheriting the environment.\nfunc (CommandService) runCommand(name string, args ...string) error {\n\tcmd := exec.Command(name, args...)\n\tcmd.SysProcAttr = &syscall.SysProcAttr{\n\t\tSetpgid: true,\n\t}\n\tcmd.Env = os.Environ()\n\treturn cmd.Run()\n}\n","sourceCodeStart":51,"sourceCodeEnd":84,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/app/command_service.go#L51-L84","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nsvc.OpenFile(\"removed-plugin.5m.py\") // file no longer exists\n// after\np := filepath.Join(pluginDirectory, name)\nif _, err := os.Stat(p); err == nil {\n    svc.OpenFile(name)\n}","handlingStrategy":"validation","validationCode":"// before OpenFile: verify the joined path exists\ntarget := filepath.Join(pluginDirectory, relPath)\nif _, err := os.Stat(target); err != nil {\n    return fmt.Errorf(\"plugin file %q not found\", relPath)\n}","typeGuard":null,"tryCatchPattern":"// Go\nif err := svc.OpenFile(relPath); err != nil {\n    if strings.Contains(err.Error(), \"failed to open\") {\n        return fmt.Errorf(\"cannot edit plugin %q: %w\", relPath, err)\n    }\n    return err\n}","preventionTips":["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"],"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"}