tui-cs/Terminal.Gui · error · NotSupportedException
"{_xclipPath} {xclipArgs}" failed.
Error message
"{_xclipPath} {xclipArgs}" failed. What it means
Thrown by UnixClipboard.GetClipboardDataImpl when invoking xclip to read the clipboard selection raises an exception (e.g. process failure), wrapping the original exception. It is a NotSupportedException. Note: IsSupported is determined at construction by checking that xclip exists; this error means xclip was found but the read operation itself failed at runtime.
Source
Thrown at Terminal.Gui/Drivers/UnixHelpers/UnixClipboard.cs:39
public override bool IsSupported { get; }
protected override string GetClipboardDataImpl ()
{
string tempFileName = Path.GetTempFileName ();
string xclipArgs = "-selection clipboard -o";
try
{
(int exitCode, string _) = _processRunner.Bash ($"{_xclipPath} {xclipArgs} > {tempFileName}", waitForOutput: false);
if (exitCode == 0)
{
return File.ReadAllText (tempFileName);
}
}
catch (Exception e)
{
throw new NotSupportedException ($"\"{_xclipPath} {xclipArgs}\" failed.", e);
}
finally
{
File.Delete (tempFileName);
}
return string.Empty;
}
protected override void SetClipboardDataImpl (string text)
{
string xclipArgs = "-selection clipboard -i";
try
{
_processRunner.Bash ($"{_xclipPath} {xclipArgs}", text);
}
catch (Exception e)View on GitHub (pinned to 2e47b11478)
Solutions
- Check Clipboard.IsSupported before using clipboard APIs and degrade gracefully.
- Ensure an X session is available (set DISPLAY, use ssh -X, or run under XWayland).
- Install/verify xclip is functional: run `xclip -selection clipboard -o` manually.
Example fix
// before string text = Clipboard.GetText(); // after string text = Clipboard.IsSupported ? Clipboard.GetText() : string.Empty;
Defensive patterns
Strategy: fallback
Validate before calling
if (!Clipboard.IsSupported) return string.Empty;
Type guard
static bool ClipboardReady() => Clipboard.IsSupported;
Try / catch
try { return Clipboard.GetText(); } catch (NotSupportedException) { return string.Empty; } Prevention
- Check Clipboard.IsSupported before any clipboard call.
- Do not rely on clipboard in headless/SSH-without-X sessions.
- Verify `xclip -selection clipboard -o` works in the target environment.
When it happens
Trigger: Calling Clipboard.GetText (or GetClipboardDataImpl) on Linux when xclip is installed but the read fails: no X display, xclip not in an active X/Wayland session, permission denied, or xclip killed.
Common situations: Running a Terminal.Gui app over SSH without X forwarding, headless/CI environments, Wayland without XWayland, or xclip crashes/permission issues.
Related errors
- "{_xclipPath} {xclipArgs} < {text}" failed
- Failed to copy from the OS clipboard.
- Failed to paste to the OS clipboard.
- Process timed out. Command line: {process.StartInfo.FileName
- Failed to get screenBuffer console mode, error code: {Marsha
AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13).
Data as JSON: /api/errors/334f8424c6a25a44.
Report an issue: GitHub.