{"record":{"id":"21e12a31ba0f1044","repo":"tui-cs/Terminal.Gui","slug":"xclippath-xclipargs-text-failed","errorCode":null,"errorMessage":"\"{_xclipPath} {xclipArgs} < {text}\" failed","messagePattern":"\"(.+?) (.+?) < (.+?)\" failed","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Drivers/UnixHelpers/UnixClipboard.cs","lineNumber":59,"sourceCode":"        finally\n        {\n            File.Delete (tempFileName);\n        }\n\n        return string.Empty;\n    }\n\n    protected override void SetClipboardDataImpl (string text)\n    {\n        string xclipArgs = \"-selection clipboard -i\";\n\n        try\n        {\n            _processRunner.Bash ($\"{_xclipPath} {xclipArgs}\", text);\n        }\n        catch (Exception e)\n        {\n            throw new NotSupportedException ($\"\\\"{_xclipPath} {xclipArgs} < {text}\\\" failed\", e);\n        }\n    }\n\n    private bool CheckSupport ()\n    {\n#pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception.\n        try\n        {\n            (int exitCode, string result) = _processRunner.Bash (\"which xclip\", waitForOutput: true);\n\n            if (exitCode == 0 && result.FileExists ())\n            {\n                _xclipPath = result;\n\n                return true;\n            }\n        }\n        catch (Exception)","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Drivers/UnixHelpers/UnixClipboard.cs#L41-L77","documentation":"Thrown by UnixClipboard.SetClipboardDataImpl when invoking xclip to write to the clipboard selection raises an exception, wrapping the original. It is a NotSupportedException. Note the message interpolates the text being set, which can leak clipboard contents into logs; xclip was found at construction (IsSupported true) but the write failed at runtime.","triggerScenarios":"Calling Clipboard.SetText (or SetClipboardDataImpl) on Linux when xclip is installed but the write fails: no X display, not in an X/Wayland session, permission denied, or xclip killed mid-write.","commonSituations":"SSH sessions without X forwarding, headless/CI boxes, Wayland without XWayland, or environments where xclip cannot reach a clipboard daemon.","solutions":["Check Clipboard.IsSupported before calling SetText and skip silently if unsupported.","Ensure a usable X session (DISPLAY set, ssh -X, or XWayland).","Verify manually: `echo test | xclip -selection clipboard -i`."],"exampleFix":"// before\nClipboard.SetText(value);\n\n// after\nif (Clipboard.IsSupported)\n    Clipboard.SetText(value);","handlingStrategy":"fallback","validationCode":"if (!Clipboard.IsSupported) return;","typeGuard":"static bool ClipboardReady() => Clipboard.IsSupported;","tryCatchPattern":"try { Clipboard.SetText(value); } catch (NotSupportedException) { /* ignore; clipboard unavailable */ }","preventionTips":["Check Clipboard.IsSupported before SetText.","Avoid clipboard dependency in CI/headless environments.","Be aware the exception message includes the text being set (log hygiene)."],"tags":["clipboard","unix","linux","xclip","environment","not-supported"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}