gh-copilot icon indicating copy to clipboard operation
gh-copilot copied to clipboard

[BUG]: xclip installed but "Error: failed to copy to clipboard: No clipboard utilities available"

Open ReHoss opened this issue 1 year ago • 1 comments

What happened?

Can't copy commands to the clipboard with xclip. xclip is not recognised.

Versions

hosseinkhan@mecacpt80:~$ gh --version
gh version 2.6.0-15-g1a10fd5a (2022-03-16)
https://github.com/cli/cli/releases/latest

Relevant terminal output

hosseinkhan@mecacpt80:~$ gh copilot suggest "Undo the last commit"

Welcome to GitHub Copilot in the CLI!
version 1.0.5 (2024-09-12)

I'm powered by AI, so surprises and mistakes are possible. Make sure to verify any generated code or suggestions, and share feedback so that we can learn and improve. For more information, see https://gh.io/gh-copilot-transparency

? What kind of command can I help you with?
> generic shell command

Suggestion:                                                                                                                                    
                                                                                                                                               
  git revert HEAD --no-edit                                                                                                                    

? Select an option
> Copy command to clipboard

✗ Error: failed to copy to clipboard: failed to copy to clipboard: No clipboard utilities available. Please install xsel, xclip, wl-clipboard or Termux:API add-on for termux-clipboard-get/set.

hosseinkhan@mecacpt80:~$ dpkg -l | grep xclip
ii  xclip                                                  0.13-2                                        amd64        command line interface to X selections

ReHoss avatar Dec 09 '24 14:12 ReHoss

same problem

HiddenMachine3 avatar Dec 30 '24 16:12 HiddenMachine3

7 months later I still have face the issue with the last version of gh (gh version 2.74.0-19-gea8fc856e (2025-06-09))

EDIT: @HiddenMachine3 @drienkop @GTazz

gh was installed with snap on my machine. snap isolates programmes, thus no call was made to any clipboard programme. Installing gh by following the official recommended instructions (no apt either, since it installs a 2022 version) solved the issue. (Issue resolved with the support of ChatGPT).

ReHoss avatar Aug 06 '25 09:08 ReHoss

I'm glad to hear that the issue is resolved, @ReHoss! and sorry this issue didn't get triaged by the team. 🙏

However, please note that gh is not officially shipped as a Snap package, and we explicitly advise our users about this. There's a community maintained package, but as you mentioned it has problems with strict confinement.

@HiddenMachine3, may I ask if the @ReHoss's solution worked for you?

babakks avatar Aug 06 '25 11:08 babakks