wavetermdev/waveterm · error

getting absolute path: %w

Error message

getting absolute path: %w

What it means

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).

Source

Thrown at cmd/wsh/cmd/wshcmd-editor.go:48

	rootCmd.AddCommand(editorCmd)
}

func editorRun(cmd *cobra.Command, args []string) (rtnErr error) {
	defer func() {
		sendActivity("editor", rtnErr == nil)
	}()
	if len(args) == 0 {
		OutputHelpMessage(cmd)
		return fmt.Errorf("no arguments.  wsh editor requires a file or URL as an argument argument")
	}
	if len(args) > 1 {
		OutputHelpMessage(cmd)
		return fmt.Errorf("too many arguments.  wsh editor requires exactly one argument")
	}
	fileArg := args[0]
	absFile, err := filepath.Abs(fileArg)
	if err != nil {
		return fmt.Errorf("getting absolute path: %w", err)
	}
	_, err = os.Stat(absFile)
	if err == fs.ErrNotExist {
		return fmt.Errorf("file does not exist: %q", absFile)
	}
	if err != nil {
		return fmt.Errorf("getting file info: %w", err)
	}

	tabId := getTabIdFromEnv()
	if tabId == "" {
		return fmt.Errorf("no WAVETERM_TABID env var set")
	}

	wshCmd := wshrpc.CommandCreateBlockData{
		TabId: tabId,
		BlockDef: &waveobj.BlockDef{
			Meta: map[string]any{

View on GitHub (pinned to a4447c1563)

Solutions

  1. cd to a valid directory and re-run the command
  2. Check the current working directory exists (`pwd`)
  3. Pass an absolute file path so resolution is less cwd-dependent

Example fix

// before
cd /tmp/deleted-dir && wsh editor f.txt  # error
// after
cd ~ && wsh editor f.txt
Defensive patterns

Strategy: fallback

Validate before calling

wd, err := os.Getwd()
if err != nil {
    return errors.New("working directory is invalid; cd somewhere valid first")
}

Try / catch

if err := wsh.Editor(file); err != nil {
    if strings.Contains(err.Error(), "getting absolute path") {
        abs, _ := filepath.Abs(file) // or cd to a valid dir and retry
        _ = abs
    }
}

Prevention

When it happens

Trigger: filepath.Abs returning an error, typically os.Getwd failing because the current working directory was deleted or is inaccessible.

Common situations: Shell sitting in a directory that was removed by another process; running wsh editor from a cwd the user lacks permission to stat.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/1790d8005b46c969. Report an issue: GitHub.