{"record":{"id":"1790d8005b46c969","repo":"wavetermdev/waveterm","slug":"getting-absolute-path-w","errorCode":null,"errorMessage":"getting absolute path: %w","messagePattern":"getting absolute path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-editor.go","lineNumber":48,"sourceCode":"\trootCmd.AddCommand(editorCmd)\n}\n\nfunc editorRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tdefer func() {\n\t\tsendActivity(\"editor\", rtnErr == nil)\n\t}()\n\tif len(args) == 0 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"no arguments.  wsh editor requires a file or URL as an argument argument\")\n\t}\n\tif len(args) > 1 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"too many arguments.  wsh editor requires exactly one argument\")\n\t}\n\tfileArg := args[0]\n\tabsFile, err := filepath.Abs(fileArg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting absolute path: %w\", err)\n\t}\n\t_, err = os.Stat(absFile)\n\tif err == fs.ErrNotExist {\n\t\treturn fmt.Errorf(\"file does not exist: %q\", absFile)\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting file info: %w\", err)\n\t}\n\n\ttabId := getTabIdFromEnv()\n\tif tabId == \"\" {\n\t\treturn fmt.Errorf(\"no WAVETERM_TABID env var set\")\n\t}\n\n\twshCmd := wshrpc.CommandCreateBlockData{\n\t\tTabId: tabId,\n\t\tBlockDef: &waveobj.BlockDef{\n\t\t\tMeta: map[string]any{","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-editor.go#L30-L66","documentation":"After validating the argument count, editorRun converts the file argument to an absolute path via filepath.Abs; failure of that OS-level call is wrapped as \"getting absolute path\". filepath.Abs rarely fails (it can fail when resolving the working directory, e.g. a deleted cwd).","triggerScenarios":"filepath.Abs returning an error, typically os.Getwd failing because the current working directory was deleted or is inaccessible.","commonSituations":"Shell sitting in a directory that was removed by another process; running wsh editor from a cwd the user lacks permission to stat.","solutions":["cd to a valid directory and re-run the command","Check the current working directory exists (`pwd`)","Pass an absolute file path so resolution is less cwd-dependent"],"exampleFix":"// before\ncd /tmp/deleted-dir && wsh editor f.txt  # error\n// after\ncd ~ && wsh editor f.txt","handlingStrategy":"fallback","validationCode":"wd, err := os.Getwd()\nif err != nil {\n    return errors.New(\"working directory is invalid; cd somewhere valid first\")\n}","typeGuard":null,"tryCatchPattern":"if err := wsh.Editor(file); err != nil {\n    if strings.Contains(err.Error(), \"getting absolute path\") {\n        abs, _ := filepath.Abs(file) // or cd to a valid dir and retry\n        _ = abs\n    }\n}","preventionTips":["Avoid running commands from deleted directories","Pass absolute paths to wsh editor","Re-create/re-enter the working directory if it was removed"],"tags":["filesystem","path-resolution","cli"],"backgroundTag":"path-resolution-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}