Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use clipr::dr_clipr() #105

Closed
gvdr opened this issue Sep 20, 2017 · 13 comments
Closed

Use clipr::dr_clipr() #105

gvdr opened this issue Sep 20, 2017 · 13 comments

Comments

@gvdr
Copy link

gvdr commented Sep 20, 2017

Clipboard is not generally available on Linux. Following the minimum example provided (copying to clipboard y <- 1:4) I got:

reprex()
#> No input provided and clipboard is not available.
#> Rendering reprex...
#> Unable to put result on the clipboard. How to get it:
#>   * Capture what reprex() returns.
#>   * Use `outfile = "foo"` to request output in specific file.
#>   * See the temp file:
#>     - /tmp/RtmpSKU1b1/file46ab29804967_reprex.md

Clipr provides also a solution:

clipr_available()
#> [1] FALSE
read_clip()
#> Error: Clipboard on X11 requires 'xclip' (recommended) or 'xsel'.

And in fact, having installed xclip, everything seems to be working fine. 👍

However, the solution is maybe not so straightforward to find? I'd suggest to put a line somewhere suggesting Linux users to install xclip if they want to run reprex.

@jennybc
Copy link
Member

jennybc commented Sep 20, 2017

@mdlincoln What would be the most official way for me to delegate messaging about this to clipr? I already use clipr_available() internally, but it returns logical. What I really need is a way put the right message in front of the user's eyeballs when clipr_available() returns FALSE.

@mdlincoln
Copy link
Contributor

Hm, good question. Possible solution:

Add a message = TRUE/FALSE argument to clipr_available() that would send a message() with that installation suggestion text when returning FALSE?
a. Or a warning()?

@jennybc
Copy link
Member

jennybc commented Sep 20, 2017

Here in reprex, I would handle with a closure so that I only message upon the first attempt to use the clipboard. Maybe you need a clipr "doctor" function that either emits an "all clear" or OS-appropriate advice on how to make the clipboard available? For now I can presumably catch the error from read_clip() to approximate this.

@mdlincoln
Copy link
Contributor

That does sound more elegant. I'll have to read up a bit on how to build that in to clipr, and will keep you posted.

@jennybc
Copy link
Member

jennybc commented Sep 20, 2017

I think this is more elaborate than you need, but something along the lines of here::dr_here() would be really useful.

https://github.com/krlmlr/here/blob/93593ee1e04d456d33199795c1d6491bd9b84164/R/here.R#L25-L54

You have all the ingredients (checking availability and suggesting remedies), just not packaged in a doctor function.

devtools::dr_github() is also inspiring (and also more involved than what clipr needs).

@gvdr
Copy link
Author

gvdr commented Sep 20, 2017

Just as a side: my idea was more humbly to just include a line warning of this potential problem in the README.md. Obviously, the solution that you are building is much stronger.

@mdlincoln
Copy link
Contributor

Indeed @gvdr, but your issue definitely highlights something that clipr should handle more transparently, especially since many people will be using clipr when it's called by other packages like reprex.

@jennybc
Copy link
Member

jennybc commented Sep 29, 2017

I'm adding one bullet to my message and will upgrade the approach when/if clipr::dr_clipr() exists.

> Sys.setenv("CLIPBOARD_AVAILABLE" = FALSE)
> reprex(1:4)
Rendering reprex...
Unable to put result on the clipboard. How to get it:
  * Unix-like systems may require explicit installation of xclip or xsel. 
  * Capture what reprex() returns.
  * Use `outfile = "foo"` to request output in specific file.
  * Use `outfile = NA` to request output in working directory.
  * For now, see the temp file:
    - /private/var/folders/vr/gzrbtprx6ybg85y5pvwm1ct40000gn/T/RtmpOnN9lT/file735b4d40d67_reprex.md

@mdlincoln
Copy link
Contributor

I actually have some time to look at this over the next day - I'll keep you updated @jennybc!

@mdlincoln
Copy link
Contributor

OK, the latest build of clipr now has a dr_clipr() method. When you can, mind giving it a spin and let me know if you've any suggestions before I mint a CRAN release?

@jennybc
Copy link
Member

jennybc commented Sep 30, 2017

I'm going to reopen this so I don't forget to test drive dr_clipr()!

@jennybc jennybc reopened this Sep 30, 2017
@jennybc jennybc changed the title Clipboard not available on Linux Use clipr::dr_clipr() Oct 13, 2017
@mdlincoln
Copy link
Contributor

@jennybc I totally forgot about minting a new CRAN release =_= but I will by the end of this week! Let me know if you spot any issues with dr_clipr() before then :)

@jennybc
Copy link
Member

jennybc commented Oct 24, 2017

OK. I don't think I've given it a whirl yet but will try do to do! reprex is also basically ready for a new release. I am waiting on a few dependencies to appear or update on CRAN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants