junegunn/fzf · error

could not create BLOCK profile: %w

Error message

could not create BLOCK profile: %w

What it means

In a pprof build, fzf could not create the block-profile output file specified by --profile-block. The runtime block rate is set first, then os.Create is attempted; failure aborts with the wrapped OS error.

Source

Thrown at src/options_pprof.go:58

		}
	}

	if o.MEMProfile != "" {
		f, err := os.Create(o.MEMProfile)
		if err != nil {
			return fmt.Errorf("could not create MEM profile: %w", err)
		}
		util.AtExit(func() {
			runtime.GC()
			stopProfile("allocs", f)
		})
	}

	if o.BlockProfile != "" {
		runtime.SetBlockProfileRate(1)
		f, err := os.Create(o.BlockProfile)
		if err != nil {
			return fmt.Errorf("could not create BLOCK profile: %w", err)
		}
		util.AtExit(func() { stopProfile("block", f) })
	}

	if o.MutexProfile != "" {
		runtime.SetMutexProfileFraction(1)
		f, err := os.Create(o.MutexProfile)
		if err != nil {
			return fmt.Errorf("could not create MUTEX profile: %w", err)
		}
		util.AtExit(func() { stopProfile("mutex", f) })
	}

	return nil
}

View on GitHub (pinned to bd4efa277b)

Solutions

  1. Create and verify the output directory: mkdir -p /tmp/prof && touch /tmp/prof/block.out
  2. Use /tmp or another guaranteed-writable path
  3. Read the wrapped error for the precise cause

Example fix

# before
fzf --profile-block ./out/block.prof   # ./out missing
# after
mkdir -p ./out && fzf --profile-block ./out/block.prof
Defensive patterns

Strategy: validation

Validate before calling

d=/tmp/fzf-prof; mkdir -p "$d" && [ -w "$d" ] || exit 1
fzf --profile-block "$d/block.prof"

Prevention

When it happens

Trigger: Passing --profile-block with a path in a nonexistent/read-only directory or a path that is itself a directory.

Common situations: Profiling scripts assuming a scratch directory exists; read-only containers where the only writable path is /tmp.

Related errors


AI-assisted analysis of junegunn/fzf@bd4efa277b (2026-08-15). Data as JSON: /api/errors/752029fa0bdda23a. Report an issue: GitHub.