rlinuxreprex

Reprex error on Linux: No input provided and clipboard is not available


Unable to generate reprex on Linux. When I try a simple example

  (y <- 1:4)
  mean(y)

I get the following message

No input provided and clipboard is not available.
Rendering reprex...
Clipboard on X11 requires 'xclip' (recommended) or 'xsel'.
Unable to put result on the clipboard. How to get it:
* Capture what `reprex()` returns.
* Consult the output file. Control via `outfile` argument.
Path to `outfile`:
    * /tmp/RtmpRYA93G/reprex16f2e48b49ed7/reprex_reprex.md
Open the output file for manual copy?
1: yes
2: no

and the following output in my viewer

 No user-supplied code found … so we’ve made some up. You’re welcome!

 sprintf("Happy %s!", weekdays(Sys.Date()))
 #> [1] "Happy Friday!"
 Created on 2020-10-16 by the reprex package (v0.3.0.9001)

Is it a clipboard issue on Linux? Thanks for helping out.


Solution

  • Clipboard is not generally available on Linux and users have to install xclip if they want to run reprex. An alternative is to not use the clipboard as suggested in MrFlick's comment

    reprex::reprex({(y <- 1:4); mean(y)})