tui-cs/Terminal.Gui · warning · NotSupportedException
Failed to copy from the OS clipboard.
Error message
Failed to copy from the OS clipboard.
What it means
Thrown by ClipboardBase.GetClipboardData when the platform-specific GetClipboardDataImpl throws NotSupportedException. The wrapper re-throws a new NotSupportedException with a friendlier message, preserving the original as InnerException. This typically means the OS clipboard helper (xclip/xsel/pbcopy/wl-paste, or the Windows clipboard API) is unavailable or the environment does not support clipboard access.
Source
Thrown at Terminal.Gui/App/Clipboard/ClipboardBase.cs:30
/// <summary>Returns the contents of the OS clipboard if possible.</summary>
/// <returns>The contents of the OS clipboard if successful.</returns>
/// <exception cref="NotSupportedException">Thrown if it was not possible to copy from the OS clipboard.</exception>
public string GetClipboardData ()
{
try
{
string result = GetClipboardDataImpl ();
if (result is null)
{
return string.Empty;
}
return result;
}
catch (NotSupportedException ex)
{
throw new NotSupportedException ("Failed to copy from the OS clipboard.", ex);
}
}
/// <summary>Pastes the <paramref name="text"/> to the OS clipboard if possible.</summary>
/// <param name="text">The text to paste to the OS clipboard.</param>
/// <exception cref="NotSupportedException">Thrown if it was not possible to paste to the OS clipboard.</exception>
public void SetClipboardData (string text)
{
if (text is null)
{
throw new ArgumentNullException (nameof (text));
}
try
{
SetClipboardDataImpl (text);
}
catch (NotSupportedException ex)View on GitHub (pinned to 2e47b11478)
Solutions
- Before reading, check Application.Driver?.Clipboard?.IsSupported and use TryGetClipboardData which returns false instead of throwing.
- Install the required clipboard helper on Linux: apt-get install xclip (or xsel, or wl-clipboard for Wayland).
- Run in an environment with a real clipboard (interactive desktop session) rather than headless/redirected.
- Catch NotSupportedException and degrade gracefully (e.g. disable paste functionality).
Example fix
// before
string text = Application.Driver.Clipboard.GetClipboardData (); // may throw
// after
if (Application.Driver?.Clipboard?.IsSupported == true)
{
string text = Application.Driver.Clipboard.GetClipboardData ();
} Defensive patterns
Strategy: try-catch
Validate before calling
if (Application.Driver?.Clipboard?.IsSupported == true)
{
string text = Application.Driver.Clipboard.GetClipboardData ();
} Type guard
static bool ClipboardAvailable () => Application.Driver?.Clipboard?.IsSupported == true;
Try / catch
try
{
string text = Application.Driver.Clipboard.GetClipboardData ();
}
catch (NotSupportedException ex)
{
Logging.Warning ($"Clipboard read unavailable: {ex.Message}");
text = string.Empty;
} Prevention
- Check IsSupported before reading the clipboard.
- Prefer TryGetClipboardData which returns false instead of throwing.
- Ensure xclip/xsel/wl-paste is installed on Linux.
When it happens
Trigger: Reading the clipboard on a headless Linux without xclip/xsel/wl-paste installed; running over SSH without clipboard forwarding; a CI/container environment with no clipboard daemon; the terminal redirecting input/output (ClipboardProcessRunner bails early in that case).
Common situations: Headless servers, Docker containers, SSH sessions, CI pipelines; Linux distros missing the clipboard helper binaries; Wayland vs X11 mismatches where the wrong helper is invoked.
Related errors
- Failed to paste to the OS clipboard.
- Process timed out. Command line: {process.StartInfo.FileName
- "{_xclipPath} {xclipArgs}" failed.
- "{_xclipPath} {xclipArgs} < {text}" failed
- Driver '{driverName}' is not registered in DriverRegistry.
AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13).
Data as JSON: /api/errors/650ae8466e902ffd.
Report an issue: GitHub.