wavetermdev/waveterm · error

opening log file: %w

Error message

opening log file: %w

What it means

tailLogFile could not os.Open the log file at the path returned by the server. Since --tail reads the log directly from the local filesystem, this fails when the file is absent, unreadable, or the path is a directory.

Source

Thrown at cmd/wsh/cmd/wshcmd-wavepath.go:89

		return fmt.Errorf("getting path: %w", err)
	}

	if tail && pathType == "log" {
		err = tailLogFile(path)
		if err != nil {
			return fmt.Errorf("tailing log file: %w", err)
		}
		return nil
	}

	WriteStdout("%s\n", path)
	return nil
}

func tailLogFile(path string) error {
	file, err := os.Open(path)
	if err != nil {
		return fmt.Errorf("opening log file: %w", err)
	}
	defer file.Close()

	// Get file size
	stat, err := file.Stat()
	if err != nil {
		return fmt.Errorf("getting file stats: %w", err)
	}

	// Read last 16KB or whole file if smaller
	readSize := int64(16 * 1024)
	var offset int64
	if stat.Size() > readSize {
		offset = stat.Size() - readSize
	}

	_, err = file.Seek(offset, 0)
	if err != nil {

View on GitHub (pinned to a4447c1563)

Solutions

  1. Verify the file exists: `ls -l "$(wsh wavepath log)"`.
  2. Fix permissions (`chmod`/run as terminal owner).
  3. Ensure Wave has actually written a log file (start the terminal once).
  4. Retry after rotation completes.

Example fix

// before
file, err := os.Open(path)
// after
if _, err := os.Stat(path); os.IsNotExist(err) { return fmt.Errorf("log file %s does not exist yet", path) }
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Stat(path); err != nil { /* skip tailing */ }

Type guard

func canOpen(path string) bool { f, err := os.Open(path); if err != nil { return false }; f.Close(); return true }

Try / catch

if err := tailLogFile(path); err != nil { log.Printf("tail skipped: %v", err); return nil }

Prevention

When it happens

Trigger: `wsh wavepath log --tail` when the log file has been deleted/rotated, the user lacks read permission, the path doesn't exist, or the path is a directory.

Common situations: Log rotation, fresh Wave install with no waveterm.log yet, running wsh under a different user (sudo/CI) than the terminal owner.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


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