ipfs/kubo · error

file does not support seeking

Error message

file does not support seeking

What it means

`ipfs cat` supports an offset by seeking within the opened file. The code type-asserts the underlying reader to io.Seeker; if it does not implement it (certain DAG readers or non-seekable streams), cat returns `file does not support seeking` instead of a byte offset.

Source

Thrown at core/commands/cat.go:162

		case files.Directory:
			return nil, 0, iface.ErrIsDir
		default:
			return nil, 0, iface.ErrNotSupported
		}

		fsize, err := file.Size()
		if err != nil {
			return nil, 0, err
		}

		if offset > fsize {
			offset = offset - fsize
			continue
		}

		seeker, ok := file.(io.Seeker)
		if !ok {
			return nil, 0, fmt.Errorf("file does not support seeking")
		}
		count, err := seeker.Seek(offset, io.SeekStart)
		if err != nil {
			return nil, 0, err
		}
		offset = 0

		fsize, err = file.Size()
		if err != nil {
			return nil, 0, err
		}

		size := uint64(fsize - count)
		length += size
		if max > 0 && length >= uint64(max) {
			var r io.Reader = file
			if overshoot := int64(length - uint64(max)); overshoot != 0 {
				r = io.LimitReader(file, int64(size)-overshoot)

View on GitHub (pinned to 329838acdf)

Solutions

  1. Omit --offset and stream from the start, discarding bytes client-side until the desired offset
  2. Convert the content to a standard UnixFS layout (re-add with default settings) so it is seekable
  3. Fetch the whole file then slice locally: `ipfs get <cid>` and use dd/tail
  4. Check the content type/DAG layout with `ipfs dag stat` or `ipfs ls`

Example fix

// before
ipfs cat $CID --offset 1000   # non-seekable reader
// after
ipfs get $CID -o /tmp/f && dd if=/tmp/f bs=1 skip=1000
Defensive patterns

Strategy: fallback

Validate before calling

null

Type guard

if seeker, ok := file.(io.Seeker); ok {
    _, err := seeker.Seek(offset, io.SeekStart)
    // seekable
} else {
    // fallback: read-and-discard or ipfs get then slice
}

Try / catch

if err != nil && strings.Contains(err.Error(), "does not support seeking") {
    // fallback: stream from 0 and discard offset bytes client-side
}

Prevention

When it happens

Trigger: `ipfs cat` with an offset on content whose reader does not implement io.Seeker (e.g. certain UnixFS node types or streaming readers), failing the Seek type assertion.

Common situations: Catting compressed/special node types or exotic DAG layouts with --offset; using the RPC API with offset on content that is streamed rather than seekable.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/dad7cc02ff9f4a44. Report an issue: GitHub.