charmbracelet/crush · info
clipboard operations are not supported on this platform
Error message
clipboard operations are not supported on this platform
What it means
clipboard.ErrUnsupported is returned when clipboard access is unavailable on the current platform. The clipboard package uses build tags: fully supported platforms get real implementations, while platforms without support (Android, iOS, or builds without CGO) compile in stub initClipboard/read that return this sentinel. Init is safe to call and simply reports ErrUnsupported instead of panicking.
Source
Thrown at internal/clipboard/clipboard.go:21
// requiring CGO or platform-specific dependencies.
package clipboard
import "errors"
// Format identifies the kind of data to read from the clipboard.
type Format int
const (
// FormatText is plain UTF-8 text.
FormatText Format = iota
// FormatImage is binary image data (PNG).
FormatImage
)
var (
// ErrUnsupported is returned when clipboard access is not available on
// the current platform.
ErrUnsupported = errors.New("clipboard operations are not supported on this platform")
// ErrEmpty is returned when the clipboard holds no data for the
// requested format.
ErrEmpty = errors.New("clipboard is empty or holds an unsupported format")
)
// Init initializes the clipboard subsystem. On unsupported platforms it
// returns ErrUnsupported but is otherwise safe to call.
func Init() error {
return initClipboard()
}
// WriteText writes plain text to the system clipboard. On unsupported
// platforms it is a no-op.
func WriteText(text string) {
writeText(text)
}
// Read returns the clipboard contents for the given format. It returnsView on GitHub (pinned to 7944b8e522)
Solutions
- Guard clipboard usage with errors.Is(err, clipboard.ErrUnsupported) and degrade gracefully (disable paste-image features).
- Rebuild for the target platform with CGO enabled and the platform clipboard dependencies installed (e.g. xclip/xsel/wl-clipboard on Linux).
- Call clipboard.Init() once at startup and record support status instead of relying on Read at use time.
Example fix
// before
data, err := clipboard.Read(clipboard.FormatImage)
if err != nil {
return err
}
// after
data, err := clipboard.Read(clipboard.FormatImage)
if errors.Is(err, clipboard.ErrUnsupported) {
return nil // no clipboard on this platform; skip feature
}
if err != nil {
return err
} Defensive patterns
Strategy: fallback
Validate before calling
// Probe clipboard support once at startup clipboardSupported := clipboard.Init() == nil
Type guard
func clipboardAvailable() bool { return !errors.Is(clipboard.Init(), clipboard.ErrUnsupported) } Try / catch
data, err := clipboard.Read(clipboard.FormatText)
if errors.Is(err, clipboard.ErrUnsupported) {
return nil // degrade: disable paste feature on this platform
}
if err != nil {
return err
} Prevention
- Call Init() early and gate clipboard-dependent UI features on its result.
- Build with the correct platform tags/CGO settings for targets that need clipboard support.
- Treat ErrUnsupported as a permanent capability gap, never retry it.
When it happens
Trigger: Calling clipboard.Init() or clipboard.Read(FormatText|FormatImage) on a platform compiled without clipboard support (the clipboard_not_supported.go build-tag variant); any write is a silent no-op on those platforms.
Common situations: Running crush on Android/iOS (e.g. via Termux-like environments), cross-compiling with CGO_ENABLED=0 for a target whose clipboard backend requires CGO, or running in minimal containers/SSH sessions without a clipboard service.
Related errors
- clipboard is empty or holds an unsupported format
- unsupported by the running server
- Crush crashed. If metrics are enabled, we were notified abou
- empty providers list from catwalk
- file lock is held by another process
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/0c67b07286e81092.
Report an issue: GitHub.