terminal: Windows terminal randomly freezes with Neovim 0.6 in debian Bullseye when using MCTRL>-C or V

Windows Terminal version

1.11.2921.0

Windows build number

10.0.22000.348

Other Software

  1. Install Debian Bullseye from the store using my powershell scripts:
    https://github.com/nicenemo/wsl-debian-boxes
  2. Install NeoVM 0.6 from source https://github.com/neovim/neovim.
  3. Install lunarvim https://www.lunarvim.org/#opinionated
  4. Use SauceCode PRO NF font
  5. Use GruvBox Material Medium dark color scheme
  6. Software installed with Ansible using my playbook
    https://github.com/nicenemo/win-dev-playbook Only The Debian stuff. Calling chocolatey is not working perfect yet and therefore commented out.
  7. Install OhMyPosh in Bash and ZSH
  8. I have systemd enabled with Distrod after installing my own updated Debian. https://github.com/nullpo-head/wsl-distrod Then I have a bash shell. However the same also happens without having distrod enabling systemd.
  9. Memory in WSL is 24Gb and swap of 24Gb. 10 System Thinkpad T480 with 32Gb of memory. (But also have this on a HP Prodesk 400 G4.) And can test it on a T450s with Windows 10.
  10. all updates installed.

fragments of my config

[...]
"font": 
                {
                    "face": "SauceCodePro NF"
                },
[...]

Use color scheme:

[...]
 "colorScheme": "GruvboxMaterialMediumDark",
[...]
 {
            "background": "#282828",
            "black": "#665C54",
            "blue": "#7DAEA3",
            "brightBlack": "#928374",
            "brightBlue": "#7DAEA3",
            "brightCyan": "#89B482",
            "brightGreen": "#A9B665",
            "brightPurple": "#D3869B",
            "brightRed": "#EA6962",
            "brightWhite": "#D4BE98",
            "brightYellow": "#D8A657",
            "cursorColor": "#FFFFFF",
            "cyan": "#89B482",
            "foreground": "#D4BE98",
            "green": "#A9B665",
            "name": "GruvboxMaterialMediumDark",
            "purple": "#D3869B",
            "red": "#EA6962",
            "selectionBackground": "#FFFFFF",
            "white": "#D4BE98",
            "yellow": "#D8A657"
        },

Linux config:

[...]
 {
                "closeOnExit": "always",
                "colorScheme": "GruvboxMaterialMediumDark",
                "font": 
                {
                    "face": "SauceCodePro NF"
                },
                "guid": "{c31b85d2-61c0-5be6-9284-2ac955dcc417}",
                "hidden": false,
                "name": "nemolinux",
                "source": "Windows.Terminal.Wsl",
                "startingDirectory": "\\\\wsl.localhost\\nemolinux\\home\\kruse"
            },
[...]

Steps to reproduce

  1. Edit in neovim with lunarvim: Mardown, JSON, Ruby, Java, logstash config, does not really matter.
  2. Then copy something from Chrome on Windows, e.g. stackoverflow or from notepad or email.
  3. try to paste with ‘<kbd>CTRL+SHIFT+V</kbd>’
  4. Sometimes the terminal freezes, sometimes not.
  5. Outside neovim try to copy something in the terminal with ‘<kbd>CTRL+SHIFT+C</kbd>’
  6. Sometimes the terminal freezes, sometimes not.
  7. I have to kill the terminal in the task manager. It is no using High CPU nor is anything else.
  8. Resizing the terminal or switching tabs if I have multiple terminal tabs is not possible either.
  9. Also maximize or minimize does not work.

Happens in Windows 10 as well as Windows 11. With Release and preview version.

Expected Behavior

Copy and Paste just works in a Debian terminal.

Actual Behavior

Terminal freezes sometimes when trying to copy or paste with Control Shift-C or Control-Shift V. I experience it more often in NeoVIM with LunarVIM. Also had this in Windows 10 in the past.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 11
  • Comments: 54 (19 by maintainers)

Commits related to this issue

Most upvoted comments

@DrGGCoolman thanks! Did it yesterday and noticed some other weird issues (sometimes it would print in neovim that it was an error when yanking: related issue). Compiled a PR that wasn’t merged and uploaded it in my own branch for now until they resolve and merge it (over a year old though).

Running the following now when setting up win32yank.

curl -sLo/tmp/win32yank.zip https://github.com/robertbrunhage/win32yank/releases/download/v0.0.5/win32yank-x64.zip
unzip -p /tmp/win32yank.zip win32yank.exe > /tmp/win32yank.exe
chmod +x /tmp/win32yank.exe
sudo mv /tmp/win32yank.exe /usr/local/bin/

and this in neovim:

if has('wsl')
    let g:clipboard = {
          \   'name': 'wslclipboard',
          \   'copy': {
          \      '+': '/usr/local/bin/win32yank.exe -i --crlf',
          \      '*': '/usr/local/bin/win32yank.exe -i --crlf',
          \    },
          \   'paste': {
          \      '+': '/usr/local/bin/win32yank.exe -o --lf',
          \      '*': '/usr/local/bin/win32yank.exe -o --lf',
          \   },
          \   'cache_enabled': 1,
          \ }
endif

Now it seems to run flawlessly!

Sorry, to clarify - when the Terminal is in the hung state, in another powershell window, call that

Started happening again today. Following the link you sent, I then found this and then added the following to my nvim config (along with the comment to use has("wsl") for neovim:

if has("wsl")
  augroup Yank
    autocmd!
    autocmd TextYankPost * :call system('clip.exe ',@")
  augroup END
endif

Which still yields freezing

I just updated my WSL and started experiencing this error on yank. I was also using Neovim, but v0.4.4 app image. Using xsel made neovim freeze on open, but updating my neovim app image to v0.8.2 made everything run fine.

@tusharsnn I have uninstalled xclip and installed xsel and since then for the last few days I have not experienced this annoying problem. I didn’t want to reply before I was sure. Thanks a lot!

I may have found the root cause. The issue seems to be that xclip prematurely exits without waiting for paste events. This can be seen every time wsl is booted from shutdown, but it also happens when xclip is not working in the background for a long time.

$ echo "hello" | xclip -verbose -selection c
Connected to X server.
Using selection: XA_CLIPBOARD
Using UTF8_STRING.
Waiting for selection requests, Control-C to quit
  Waiting for selection request number 1

It exits right after printing this output. If I now try to paste on any windows application, it would freeze.

Now terminate wsl with wsl --shutdown then open a new tab in the terminal and run the same command twice without trying to paste in-between. You can see the xclip is waiting for the paste event and pasting would not freeze like before.

So what are you using as a clipboard manager now? xclip? Can you try using xsel instead and see if it makes a difference? In order to check if it was xclip I installed it back and suffered multiple freezes within 10 mins of constantly copy-pasting across wsl and windows.

I can say few things about the issue:

  1. Its not specific to neovim or windows terminal, as using echo "hello" | xclip -selection clipboard also freezes on its own. And pasting on MS Edge also freezes.
  2. It only hangs when the we paste the item and not while copying.
  3. Issue is not specific to Thinkpads.

@RobertBrunhage I think the easiest way is to just check where on your path win32yank is registered, so on wsl just run which win32yank.exe for me it was /usr/local/bin/win32yank.exe. Then delete it and run :checkhealth inside of neovim to make sure there is no alternative version somewhere else. image once neovim says there is no registered clipboard provider (or lists something like xclip) you can go ahead and drop the latest version of win32yank into /usr/local/bin from here win32yank release v0.0.4 run :checkhealth again and make sure neovim recognizes win32yank and you’re done 😃

Upgraded win32yank to version v0.0.4 no issues since. Spent the whole day coding so I guess this resolves the issue (at least on neovims side)