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

clipboard: error -2 #28

Closed
Freed-Wu opened this issue Aug 29, 2021 · 9 comments
Closed

clipboard: error -2 #28

Freed-Wu opened this issue Aug 29, 2021 · 9 comments

Comments

@Freed-Wu
Copy link

Sometimes I start my neovim, this error occurs:

" || clipboard: error -2
" || Error detected while processing function
" autoload/yoink.vim|438| yoink#onVimEnter[1]
" autoload/yoink.vim|354| yoink#addCurrentDefaultRegToHistory[2]
" autoload/yoink.vim|374| yoink#getDefaultYankInfo[1]
" autoload/yoink.vim|386| yoink#getYankInfoForReg[1]
" /usr/share/nvim/runtime/autoload/provider/clipboard.vim|234| provider#clipboard#Call[6]
" /usr/share/nvim/runtime/autoload/provider/clipboard.vim|161| 49[8]
" || E691: Can only compare List with List
" || Error detected while processing function
" autoload/yoink.vim|438| yoink#onVimEnter[1]
" autoload/yoink.vim|354| yoink#addCurrentDefaultRegToHistory[2]
" autoload/yoink.vim|374| yoink#getDefaultYankInfo[1]
" autoload/yoink.vim|386| yoink#getYankInfoForReg[1]
" /usr/share/nvim/runtime/autoload/provider/clipboard.vim|234| provider#clipboard#Call[6]
" /usr/share/nvim/runtime/autoload/provider/clipboard.vim|161| 49[8]
" || E15: Invalid expression: match(&clipboard, '\v(unnamed|unnamedplus)') >= 0 && get(s:selections[a:reg].data, 0, []) == clipboard_data
" || Error detected while processing function
" autoload/yoink.vim|438| yoink#onVimEnter[1]
" autoload/yoink.vim|354| yoink#addCurrentDefaultRegToHistory[2]
" autoload/yoink.vim|374| yoink#getDefaultYankInfo[1]
" autoload/yoink.vim|386| yoink#getYankInfoForReg[1]
" || clipboard: provider returned invalid data

The error sometimes occur, So I have not found any regular pattern, reason or any method to reproduce it. I have to disable this autocmd to avoid it.

I use neovim 0.5.0 on linux 5.13.13.

Any advice which can help me find the reason is thankful.

@svermeulen
Copy link
Owner

Any idea what is on your system clipboard when this happens?

@Freed-Wu
Copy link
Author

In my neovim,

set clipboard=unnamed,unnamedplus

I have installed xsel and xclip.

It seems that https://github.com/junegunn/vim-peekaboo also sometimes trigger clipboard: error -2. So I believe it is not the bug of vim-yoink.

@svermeulen
Copy link
Owner

What I mean though is what is the actual text on your clipboard when this bug occurs? I'm wondering if maybe that is related here, since you say that it only occurs sometimes

@Freed-Wu
Copy link
Author

I also met this error in other vim-plugin. This is the result of :reg

:registers
Type Name Content
  c  ""           \ 'hook_post_source': 'call init#yoink#post_source()',
  c  "0           \ 'hook_post_source': 'call init#yoink#post_source()',
  l  "1           \ 'hook_post_source': 'call init#yoink#post_source()',^J
  l  "2           \ 'hook_post_source': 'call init#yoink#post_source()',^J
  c  "-   I know.
Error detected while processing function provider#clipboard#Call[6]..38:
line    8:
E691: Can only compare List with List
E15: Invalid expression: match(&clipboard, '\v(unnamed|unnamedplus)') >= 0 && get(s:selections[a:reg].data, 0, []) == clipboard_data
clipboard: provider returned invalid data
Error detected while processing function provider#clipboard#Call[6]..38:
line    8:
E691: Can only compare List with List
E15: Invalid expression: match(&clipboard, '\v(unnamed|unnamedplus)') >= 0 && get(s:selections[a:reg].data, 0, []) == clipboard_data
clipboard: provider returned invalid data

@liu2g
Copy link

liu2g commented Sep 1, 2021

The same error happens to me on Manjaro kernel v5.13.12-1-MANJARO, using Neovim v0.5.0 Release build. For me, it only happens on startup so I am suspecting if there is anything initialized for the X11 clipboard broke it. It is also worth noting that I also have a laptop that runs Mint does not have this issue so maybe its clipboard manager does a good job?

Anyway, to temporarily solve it for my setup with i3, I added an exec line on i3 startup to "clean" the clipboard with /dev/null

exec --no-startup-id "xclip -sel clip < /dev/null"

For DE users, I can't think of any other solutions other than making a short shell script and set it on autostart.

#!/bin/sh

# clean clipboard with null
xclip -sel clip < /dev/null

@rtucek
Copy link

rtucek commented Sep 16, 2021

I'm having this issue with only neovim after doing some larger and overdue Manjaro dist-upgrade :/

The key-factors for this seem to be:

  • syncing yank with OS clipboard
  • yoink plugin
  • neovim v0.5.0

I can reliably reproduce it with these steps:

  1. have set clipboard=unnamedplus
  2. copy some text with y (builtin yank) from neovim
  3. close neovim
  4. re-open neovim with still having copied error in the OS clipboard causes this error at startup
clipboard: error: Error: target STRING not available
Error detected while processing function yoink#onVimEnter[1]..yoink#addCurrentDefaultRegToHistory[2]..yoink#getDefaultYankInfo[1]..yoink#getYankInfoForReg[1]..provider#clipboard#Call[6]..277:
line    8:
E691: Can only compare List with List
Press ENTER or type command to continue
Error detected while processing function yoink#onVimEnter[1]..yoink#addCurrentDefaultRegToHistory[2]..yoink#getDefaultYankInfo[1]..yoink#getYankInfoForReg[1]..provider#clipboard#Call[6]..277:
line    8:
E15: Invalid expression: match(&clipboard, '\v(unnamed|unnamedplus)') >= 0 && get(s:selections[a:reg].data, 0, []) == clipboard_data
Press ENTER or type command to continue
Error detected while processing function yoink#onVimEnter[1]..yoink#addCurrentDefaultRegToHistory[2]..yoink#getDefaultYankInfo[1]..yoink#getYankInfoForReg:
line    1:
clipboard: provider returned invalid data
Press ENTER or type command to continue

... and this error if pasting with p from that context on. However, the text gets pasted from the clipboard into the buffer:

Error detected while processing function yoink#paste[2]..provider#clipboard#Call[6]..277:
line    8:
E691: Can only compare List with List
E15: Invalid expression: match(&clipboard, '\v(unnamed|unnamedplus)') >= 0 && get(s:selections[a:reg].data, 0, []) == clipboard_data
Error detected while processing function yoink#paste:
line    2:
clipboard: provider returned invalid data
Press ENTER or type command to continue

Specifically, IF I copy into the OS clipboard via Ctrl + C from any window, via Ctrl + Shift + C from the terminal, Ctrl + [ for text selection + copying select text with y (tmux!), doing echo "foo" | xclip -selection c etc... I don't encounter the errors mentioned above. It's really only the case if and only if I open neovim + having something copied before with y into the clipboard. I guess this is the reason why other people and me observed the error as "spoardic".

A couple of additional things, worth mentioning:

@svermeulen
Copy link
Owner

What is the neovim clipboard provider that is being used? I think it should be listed with :checkhealth

@rtucek
Copy link

rtucek commented Sep 18, 2021

What is the neovim clipboard provider that is being used? I think it should be listed with :checkhealth

Mine is xclip.

@svermeulen
Copy link
Owner

So I was able to reproduce this on macos by explicitly setting g:clipboard to use xclip. I then noticed that the error went away when I upgraded to use the latest neovim from the head of master. So I think this issue was fixed on the neovim side. Possibly this issue: neovim/neovim#14967

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

4 participants