{"record":{"id":"334f8424c6a25a44","repo":"tui-cs/Terminal.Gui","slug":"xclippath-xclipargs-failed","errorCode":null,"errorMessage":"\"{_xclipPath} {xclipArgs}\" failed.","messagePattern":"\"(.+?) (.+?)\" failed\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Drivers/UnixHelpers/UnixClipboard.cs","lineNumber":39,"sourceCode":"    public override bool IsSupported { get; }\n\n    protected override string GetClipboardDataImpl ()\n    {\n        string tempFileName = Path.GetTempFileName ();\n        string xclipArgs = \"-selection clipboard -o\";\n\n        try\n        {\n            (int exitCode, string _) = _processRunner.Bash ($\"{_xclipPath} {xclipArgs} > {tempFileName}\", waitForOutput: false);\n\n            if (exitCode == 0)\n            {\n                return File.ReadAllText (tempFileName);\n            }\n        }\n        catch (Exception e)\n        {\n            throw new NotSupportedException ($\"\\\"{_xclipPath} {xclipArgs}\\\" failed.\", e);\n        }\n        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)","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Drivers/UnixHelpers/UnixClipboard.cs#L21-L57","documentation":"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.","triggerScenarios":"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.","commonSituations":"Running a Terminal.Gui app over SSH without X forwarding, headless/CI environments, Wayland without XWayland, or xclip crashes/permission issues.","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."],"exampleFix":"// before\nstring text = Clipboard.GetText();\n\n// after\nstring text = Clipboard.IsSupported ? Clipboard.GetText() : string.Empty;","handlingStrategy":"fallback","validationCode":"if (!Clipboard.IsSupported) return string.Empty;","typeGuard":"static bool ClipboardReady() => Clipboard.IsSupported;","tryCatchPattern":"try { return Clipboard.GetText(); } catch (NotSupportedException) { return string.Empty; }","preventionTips":["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."],"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"}