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

Not working under WSL2 (tcgetpgrp failed: Not a tty) #47

Open
monologconnor opened this issue Mar 8, 2023 · 8 comments
Open

Not working under WSL2 (tcgetpgrp failed: Not a tty) #47

monologconnor opened this issue Mar 8, 2023 · 8 comments

Comments

@monologconnor
Copy link

Hi, there!
I just found this plugin and installed it via lazy.nvim

When I tried this plugin under the Powershell environment, everything works well, however when I entered the :PasteImage command under the WSL environment, following error occured (I got no idea on why the error output is not selectable so I have to take screenshot. There are also some character displaying issue might due to my system language):

屏幕截图 2023-03-08 161955

I have also checked this issue #34, but it seems like not related.

Thanks for your help!

@monologconnor
Copy link
Author

Hi, just switched to another device and get the correct displaying error output like below, hope it helps

image

Thanks!

@diablozzq
Copy link

Can confirm this is an issue. Occurs in both alacritty and normal windows terminal.

With the health patch, and modifying the powershell command, I'm able to get :PasteImg working in WSL.

But the tcgetgrp failed occurs, and the terminal starts freaking out and neovim doesn't refresh the screen properly, leaving artifacts behind, until I close out of the terminal.

@diablozzq
Copy link

I just modified the powershell command in the utils file to the following, which is simpler and avoids as many special characters.

cmd_check = 'powershell.exe "(Get-Clipboard -Format Image)"'
cmd_paste = 'powershell.exe "(Get-Clipboard -Format Image).save(' .. "'%s'" .. ')"'

@diablozzq
Copy link

I did troubleshoot this to at least narrowing it down to being able to run this to reproduce this issue with neovim wigging out after :PasteImg is run.

:lua print(require('clipboard-image.utils').get_clip_content('powershell.exe "(Get-Clipboard -Format Image)"'))

And after this single command is run, neovim no longer refreshes properly. I'm guessing something to do with the os.popen.

@diablozzq
Copy link

That might actually be a neovim bug. os.executue('powershell.exe /?'), causes the same issue... Weird.

@diablozzq
Copy link

So may be two bugs.

  1. Neovim wigging out - have no clue, can reproduce with os.execute. Trying to reproduce without plugins....
  2. tcgetgrp failed. - May be a powershell path issue with using powershell from within WSL. See the scrapy issues.

scrapy/scrapy#4589

@diablozzq
Copy link

diablozzq commented Apr 20, 2023

Did some more testing. I disabled this plugin, and was able to reproduce some issues. So likely some neovim issues to resolve lol.

These fixes definitely fixed the paste not working:

cmd_check = 'powershell.exe "(Get-Clipboard -Format Image)"'
cmd_paste = 'powershell.exe "(Get-Clipboard -Format Image).save(' .. "'%s'" .. ')"'

But when we use the "os.execute" within WSL right now, it causes some issues with Neovim not refreshing.

And using os.execute with powershell.exe on WSL is what causes the tcgetgrp error. If you use it with another command, no error.

Edit: was able to use io.pipe instead of os.execute to get rid of the tcgetgrp error. Only have to figure out why neovim wiggs out now... lol

Edit2: Nvim inside tmux seems to do MUCH better at not getting bugged screen refreshing.... So tmux + io.pipe + fixed powershell command + fixed help = fully working markdown paste image.

Alternative would have been just sending the above powershell command directly to a terminal... wouldn't have been that hard.

@Ttayu
Copy link

Ttayu commented Apr 29, 2023

I fixed powershell command and create PR. #44
and also you can create a PR as your great work.

Traap added a commit to Traap/clipboard-image.nvim that referenced this issue Dec 3, 2023
Issue 47 - ekickx#47

cmd_chedk and cmd_past modified.
cmd_check = 'powershell.exe "(Get-Clipboard -Format Image)"'
cmd_paste = 'powershell.exe "(Get-Clipboard -Format Image).save(' .. "'%s'" .. ')"'

NOTE: WSL2 displays 'tcgetpgrp failed: Not a tty'.

vim.cmd("mode") added to M.insert_text function to redraw screen removes
the text. The error text is not written to current buffer.
jarossnd added a commit to jarossnd/clipboard-image.nvim that referenced this issue May 27, 2024
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