Using reprex addin on rstudio server

I have a client that is trying to use the reprex addin on RStudio Server. When we try to copy to the clipboard we get an error:

> reprex:::reprex_addin()
ℹ Rendering reprex...
Clipboard on X11 requires that the DISPLAY envvar be configured.
x 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/Rtmpobt4Is/reprex75bfd2961ee/
Open the output file for manual copy?
1: yes
2: no


After investigating this for a bit, I now think that reprex uses the clipr package. And that I can reproduce this issue with just the clipr package:

 library(clipr, lib.loc = "/usr/local/lib/R/site-library")
Welcome to clipr. See ?write_clip for advisories on writing to the clipboard in R.
> ?write_clip
> clipr_available()
> text <- "Write to clipboard"
> write_clip(text)
Error: Clipboard on X11 requires that the DISPLAY envvar be configured.

I don't have prior experience working with shiny server. Does anyone have advice on how to solve this?

cc @jennybryan who I believe wrote the reprex package.

The most recent version of reprex has some major quality of life improvements for RStudio Server and RStudio Cloud.

What I'm seeing above looks like behaviour with an earlier version of reprex.

So I'd suggested updating to the current CRAN version and having a look at the release blog post and the NEWS:

1 Like

@jennybryan That has solved my problem. Thank you so much :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.