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

Error : target STRING not available #38

Open
kaushalmodi opened this issue Sep 19, 2017 · 11 comments
Open

Error : target STRING not available #38

kaushalmodi opened this issue Sep 19, 2017 · 11 comments

Comments

@kaushalmodi
Copy link

Hello,

Many times, I end up with random error messages in my terminal like:

Error : target STRING not available

Turns out that xclip is causing those. So first off, these error messages should be prefixed with something like xclip:: so that the users know what's causing those.. below would be so much better:

xclip:: Error : target STRING not available

Can that error be fixed. The simple workaround I need to use each time that happens is echo foo | xclip -i. I wish one didn't need to do that.


We can see how confusing this error is based on following Google search results:

@PovarovDenis
Copy link

PovarovDenis commented Feb 23, 2019

Same problem. The error appears when system clipboard contains non-string value (file for example). My proposal is to print something like "Binary data" rather an error.

@sgraf812
Copy link

I'm unsure if this is related, but when I yank to "+ in vim and suspend with Ctrl+Z, I get the same error. Note that it works if I keep vim open. Resuming vim doesn't help. See https://askubuntu.com/questions/1013724/x11-clipboard-not-available-after-quitting-vim

@sgraf812
Copy link

Nevermind, my issues were due to https://wiki.ubuntu.com/ClipboardPersistence.

hwangcc23 added a commit to hwangcc23/xclip that referenced this issue May 4, 2019
Fix the issue astrand#38 (astrand#38).

Add a prefix "xclip::Error" with the error message so that the user can know what program is causing the error.
Print the id of the owner of the selection in the verbose mode so that the developer can know what program cannot fulfill the request of ConvertSelection.
hwangcc23 added a commit to hwangcc23/xclip that referenced this issue May 7, 2019
Fix the issue astrand#38 (astrand#38).

1).Add a prefix "xclip: Error: " with all error messages so that the user can know what program is causing the error.
2).Add a function errconvsel() for failure of ConvertSelection. It also prints the id of the owner of the selection so that the user can know what program cannot fulfill the request of ConvertSelection.
hwangcc23 added a commit to hwangcc23/xclip that referenced this issue May 7, 2019
Fix the issue astrand#38 (astrand#38).

1).Add a prefix "xclip: Error: " with all error messages so that the user can know what program is causing the error.
2).Add a function errconvsel() for failure of ConvertSelection. It also prints the id of the owner of the selection so that the user can know what program cannot fulfill the request of ConvertSelection.
@hackerb9
Copy link
Collaborator

I've merged in @hwangcc23 's fix for this issue which makes the error message more explicit about what the problem is. However, if the "solution" people want is to set the clipboard so any random string as suggested by the original report:

echo foo | xclip -i

then perhaps what is actually needed is for xclip to not be so verbose about errors. It can simply return an error if a target isn't available and not print anything unless -verbose is given.

What do people think?

@hackerb9
Copy link
Collaborator

hackerb9 commented Nov 5, 2020

Alternately, we could add an option to make even error messages not be printed out and then ask the neovim project (or whoever it is that is calling xclip) to use that option so logs won't get filled up by needless error messages.

The only problem is I'm not sure what that option would be called. We already used "-silent" to mean show error messages but nothing else and "-quiet" to mean be slightly more verbose than -silent and also run in the foreground. Perhaps those options should be renamed? "-silent" could be called "-background" or "-normal" and "-quiet" could be changed to "-foreground".

@ghost
Copy link

ghost commented Apr 2, 2021

I'm not sure how this is relevant, but i've been stumped by a similar issue when using xclip inside Emacs' eshell shell interpreter. E.g.:

  1. M-x eshell
  2. $SHELL -c 'echo foo | xclip -i'
  3. xclip -o

Errors out with 'Error: target STRING not available'

While if i do:

  1. M-x term
  2. $SHELL -c 'echo foo | xclip -i'
  3. xclip -o

I get foo back.

Is this relevant to this issue?

@krishenm94
Copy link

Any progress on this? getting a related issue with nvim.

neovim/neovim#15478

@hackerb9
Copy link
Collaborator

hackerb9 commented Aug 25, 2021

I'm not sure how this is relevant, but i've been stumped by a similar issue when using xclip inside Emacs' eshell shell interpreter.

@polezaivsani Your issue is relevant in that it appears the "error" is that xclip is reporting an error.

I asked what people thought about this almost a year ago:

I believe what is actually needed is for xclip to not be so verbose about errors. It can simply return an error if a target isn't available and not print anything unless -verbose is given.

I didn't get any response, which I suppose is appropriate as that seems to be the correct solution: say nothing. 😂

@astrand I propose the following when a TARGET is not available:

  1. Do not print an error message in simplest case, xclip -o, where we're picking a default TARGET for them.
  2. If the user specified a TARGET, then do print an informational message.

I say "informational" instead of "error" message so that we can silence it using command line options. (Xclip has no way to suppress error messages).

Does that sound good?


Eventually, we should clean up the -silent and -quiet options, neither of which suppress error messages and are confusingly intertwined with whether xclip daemonizes itself:

  1. Add -foreground and -background options that control whether xclip runs in the foreground or background (during -in)
  2. Change -silent and -quiet to only affect the verbosity level.
  3. Add a new option that also suppress error messages (as in this bug).

@Freed-Wu
Copy link

the bug affect neovim/neovim#20862

$ touch a
$ xsel -ib < a
$ xsel -ob
$ xclip -o -selection clipboard
Error: target STRING not available

justinmk pushed a commit to neovim/neovim that referenced this issue Nov 7, 2022
Problem:
xclip is not actively maintained compared to xsel, and it has a bug:

    $ touch a
    $ xsel -ib < a
    $ xsel -ob
    $ xclip -o -selection clipboard
    Error: target STRING not available

Years ago, the situation was reversed.
We originally preferred xsel 46bd3c0
but then swapped to xclip 799d9c3
to work around #7237 (comment)

Solution:
Prefer xsel again.

close #20862
ref #9302
ref astrand/xclip#38
yesean pushed a commit to yesean/neovim that referenced this issue Mar 25, 2023
Problem:
xclip is not actively maintained compared to xsel, and it has a bug:

    $ touch a
    $ xsel -ib < a
    $ xsel -ob
    $ xclip -o -selection clipboard
    Error: target STRING not available

Years ago, the situation was reversed.
We originally preferred xsel 46bd3c0
but then swapped to xclip 799d9c3
to work around neovim#7237 (comment)

Solution:
Prefer xsel again.

close neovim#20862
ref neovim#9302
ref astrand/xclip#38
@ilya-bystrov
Copy link

Came here after googling. Probably, could be helpful for someone.

I had the similar issue with my clipboard editor.

xterm -e /bin/bash -c 'xclip -o | vipe | xclip -i -sel p -f | xclip -i -sel c'

Adding -i flag fixed an issue

xterm -e /bin/bash -i -c 'xclip -o | vipe | xclip -i -sel p -f | xclip -i -sel c'

@xgqfrms
Copy link

xgqfrms commented Apr 14, 2023

this solution may help

# set $DISPLAY env ✅
$ export DISPLAY=:0.0

# bad usage ❌
$ lsusb | xclip -o >> xclip.md
Error: target STRING not available

# use multi times pipe operators 🚀
# right usage ✅ (copy fisrt,the paste)
$ lsusb | xclip -i | xclip -o >> xclip.md

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

8 participants