Writefile to /dev/tty stopped working in nvim 0.9

I’ve been using this snippet for a while…at least since neovim 0.5. I recently updated to HEAD from 0.8 and I’m seeing failures with the following line:

call writefile([escape], '/dev/tty', 'b')

I’m guessing this might be an intentional change as part of the backend separation, but I’d like to confirm that it’s not a bug before trying to find a workaround. Does anyone know why this might have changed in 0.9?


I can’t see anything in the breaking changes since Neovim 0.8.

Which is your default shell?

shell is bash 4.4 on ubuntu. I can do the following in the same shell without error:

echo "foo" > /dev/tty

…but then the writefile in that function gives:

E482: Can’t open file /dev/tty for writing: no such device or address

so I’m confused.

I just tried

:!echo foo > /dev/tty

in Neovim (0.8 and 0.9), and get

warning: An error occurred while redirecting file '/dev/tty'
open: No such device or address




not a tty

I also found this issue that seems relevant to this.
Maybe the same change has been applied to writefile, too.

I’m using the same snippet and just ran into the same issue after updating to nvim 0.9. Did you find any workaround for this?

I’ve been using this same code as a way to interact with the clipboard (I run NeoVim on a docker container and SSH into it from Windows, so that’s the only way I found to have clipboard support).

But now the latest versions of my dev container updated to nvim 0.9 and it doesn’t work anymore. Any workaround is welcome.

This plugin seems to support the script’s functionality and appears to be actively maintained.

1 Like

idk what exactly your “escape sequence” is, but if you change /dev/tty to /proc/self/fd/2 or /proc/self/fd/1, will it work again?

same issue here. i switch to a lua “system()”.

local map = function(mode, lhs, rhs, opt)
  opt = opt or {noremap = true, silent = true}
  vim.api.nvim_set_keymap(mode, lhs, rhs, opt)

yank = function(reg)
  local f = io.popen('yank', 'w')
map('n', '<c-c>', [[mzV"0y`z:lua yank(0)<cr>]])
map('v', '<c-c>', [["0y:lua yank(0)<cr>]])
map('v', '<c-x>', [["0d:lua yank(0)<cr>]])