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

[Ubuntu] --preview error : Failed to read /dev/tty #1486

Closed
12 tasks
erch opened this issue Jan 29, 2019 · 70 comments
Closed
12 tasks

[Ubuntu] --preview error : Failed to read /dev/tty #1486

erch opened this issue Jan 29, 2019 · 70 comments

Comments

@erch
Copy link

erch commented Jan 29, 2019

  • Category
    • [x ] fzf binary
    • fzf-tmux script
    • Key bindings
    • Completion
    • Vim
    • Neovim
    • Etc.
  • OS
    • [x ] Linux
    • Mac OS X
    • Windows
    • Windows Subsystem for Linux
    • Etc.
  • Shell
    • [ x] bash
    • zsh
    • fish

When I use --preview I got the error message: Failed to read /dev/tty

$ echo "hello" | fzf
hello
$ echo "hello" | fzf --preview 'echo {}'
Failed to read /dev/tty
$ echo $TERM
xterm-256color
$ tty
/dev/pts/6
$ fzf --version
0.17.5 (b46227d)
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.1 LTS
Release:	18.04
Codename:	bionic
@winvicta
Copy link

I have just run into the same problem. The problem occurred just after a system update. System is ubuntu 18.04 LTS. Before the system update, everything worked flawlessly.
Symptoms:

  1. When entering ALT-C (default binding), system responded by printing the message "Failed to read /dev/tty".
  2. When entering /dev/tty, system responded by printing "bash: /dev/tty: Permission denied"
  3. When entering tty, system responded by printing "/dev/pts/1"

"sudo chmod 777 /dev/tty" won't make a difference. uninstalling/reinstalling won't make a difference.

The other commands CTRL-R and CTRL-T work without any problems.

Any help will be appreciated. Thanks.

@bartels
Copy link

bartels commented Jan 29, 2019

I'm seeing this too. It appears to have started after an Ubuntu 18.04 kernel update to 4.15.0-44. Booting back into the previous 4.15.0-43 kernel and the error does not happen.

@ianchanning
Copy link

ianchanning commented Jan 30, 2019

  • fzf v0.17.5 (also fails with 0.17.4 but upgraded to rule anything else out)
  • Ubuntu 18.04
  • uname -a: Linux ICT0115123 4.15.0-44-generic #47-Ubuntu SMP Mon Jan 14 11:26:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

I'm hitting this problem too, it breaks the fzf.vim plugin. I get the following error in Vim:

Error running 'fzf'  '-m' '--prompt' '~/' --expect=ctrl-v,ctrl-x,ctrl-t --height=19 > /tmp/vHnZunZ/2

If I run the equivalent command I get:

channi16@ICT0115123:~$ fzf -m --prompt ~/ --expect=ctrl-v,ctrl-x,ctrl-t --height=19 > /tmp/vHnZunZ
Failed to read /dev/tty

However just running fzf at the command line typically works - although this will also sometimes fail with Failed to read /dev/tty

@ianchanning
Copy link

ianchanning commented Jan 30, 2019

I tried to track this down a bit more, it appears to be the innocuous --height parameter that causes the error:

channi16@ICT0115123:~$ fzf -m --prompt ~/ --expect=ctrl-v,ctrl-x,ctrl-t --height=14 > /tmp/vvHpkEQ
Failed to read /dev/tty
^[[3;1Rchanni16@ICT0115123:~$ fzf -m --prompt ~/
channi16@ICT0115123:~$ fzf -m --prompt ~/ --expect=ctrl-v,ctrl-x,ctrl-t
channi16@ICT0115123:~$ fzf -m --prompt ~/ --expect=ctrl-v,ctrl-x,ctrl-t --height=14
Failed to read /dev/tty
^[[7;1Rchanni16@ICT0115123:~$ ;1R

So:

  1. fzf -m --prompt ~/ works
  2. fzf -m --prompt ~/ --expect=ctrl-v,ctrl-x,ctrl-t works
  3. fzf -m --prompt ~/ --expect=ctrl-v,ctrl-x,ctrl-t --height=14 fails

And it's not in combination with any other argument:

channi16@ICT0115123:~$ fzf --height=14
Failed to read /dev/tty
^[[48;1Rchanni16@ICT0115123:~$ ;1R

@ianchanning
Copy link

ianchanning commented Jan 30, 2019

I managed to get fzf working in Vim (although it caused a core dump twice before it worked) by changing the display of fzf to be on the left rather than the bottom (my guess was this would stop using the --height param in the command) based on the README-VIM examples:

let g:fzf_layout = { 'left': '~70%' }

Actually I do still sometimes get an error:

Error running 'fzf'  '-m' '--prompt' '~/' --expect=ctrl-v,ctrl-x,ctrl-t --no-height > /tmp/vWogPww/11

But then running fzf -m --prompt ~/ --expect=ctrl-v,ctrl-x,ctrl-t --no-height on the command line works and after checking that it works in the command line restarting Vim means that it works again.

@tanc
Copy link

tanc commented Jan 30, 2019

@ianchanning that change to fzf_layout doesn't seem to help in my set up, it opens on the side but still throws the error. It may be because I'm running tmux.

@tanc
Copy link

tanc commented Jan 30, 2019

Confirmed that booting Ubuntu kernel 4.15.0-43 allows fzf to work properly. For now have uninstalled 4.15.0-44 and am booting previous kernel.

@ianchanning
Copy link

@tanc I'm not using tmux, so it could lie with that. See if you can run the same command outside Vim - I find that it will sometimes crash, but I can also get it to work with the fzf_layout change where as before calling FZF from within Vim failed all the time.

@tanc
Copy link

tanc commented Jan 30, 2019

As a working fzf in vim is such an important part of my daily work I ended up rolling back the kernel

@ianchanning
Copy link

The other option that seems to work for me is to use neovim instead. So it could be an issue around the handling of :terminal in Vim vs neovim.

@tanc
Copy link

tanc commented Jan 30, 2019

Interesting, I'm using neovim and was seeing the problem

@bartels
Copy link

bartels commented Jan 30, 2019

A likely culprit: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1813873

@lungtendo
Copy link

I'm seeing the same problem after upgrading to Linux kernel 4.15.0-44 on Ubuntu 18.04. The problem crops up randomly, it works most of the time.

@taranjlu
Copy link

taranjlu commented Jan 31, 2019

I'm new to using fzf but I believe I am running into the same issue on Linux Mint with kernel 4.18.0-14. As mentioned above, the problem appears to happen somewhat randomly. In gnome terminal, it seems to happen consistently when run from the command line, although, Ctrl+R works correctly. When using Alacritty, I also get the same error, but then it seems to start working after using Ctrl+R once.

Edit: I have fzf installed via Linuxbrew.

@lungtendo
Copy link

lungtendo commented Feb 1, 2019

Kernel version updated to 4.15.0-45 but that didn't help. Updated FZF to the latest. Still seeing the error randomly.

tadashi-aikawa added a commit to tadashi-aikawa/owl-playbook that referenced this issue Feb 1, 2019
tadashi-aikawa added a commit to tadashi-aikawa/owl-playbook that referenced this issue Feb 1, 2019
@vhakulinen
Copy link

vhakulinen commented Feb 2, 2019

After doing some research, every time I get Failed to read /dev/tty, this returns syscall.EAGAIN. This probably means that the operation needs to be tried again: https://stackoverflow.com/questions/4058368/what-does-eagain-mean

@ianchanning
Copy link

@vhakulinen this is a benefit of using neovim instead of vim, with neovim when FZF :Files fails you can retry and after a couple of times FZF will work. However in vim it causes vim to crash entirely.

@vhakulinen
Copy link

:Files is not working at all for me since I have g:fzf_layout={'up': '20%'}. If I pump it to ~70% it works randomly, but with 20% it doesn't work at all.

@bartels
Copy link

bartels commented Feb 2, 2019

@vhakulinen your findings are consistent with the ubuntu kernel bug linked above. It mentions:

a rather serious regression where userspace applications reading
from stdin can receive EAGAIN when they should not

I see the bug has been marked Fix Committed but I think it may not have been released yet. I find Launchpad pretty confusing when it comes to figuring this kind of thing out. I guess we'll see with the next kernel update.

@stephentalley
Copy link

With some trial and error, I've found that this can reliably reproduce the issue:

bash -c "sleep 1; bash -c 'echo hello'" | fzf

@kthibodeaux
Copy link

For anyone who is as impatient to have this working as I was: I was able to use https://mintguide.org/tools/691-ukuu-ubuntu-kernel-upgrade-utility.html to install a newer kernel and fix this issue.

@vhakulinen
Copy link

@bartels I think they have other status for "Fix released".

@nickgronow
Copy link

Would that apply for cosmic as well? I would participant if I could get that proposed change.

@junegunn
Copy link
Owner

@nickgronow It appears that the fix was already released for Cosmic. See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1813873/comments/21

@JiHyeongSeo
Copy link

Installing the hardware enablement stack for 18.04 seems to fix the issue. The packages are: linux-image-generic-hwe-18.04 linux-headers-generic-hwe-18.04

nice. it works!

@Karmenzind
Copy link

fixed by

apt install linux-image-generic-hwe-18.04 linux-headers-generic-hwe-18.04
apt update -y && apt upgrade -y
reboot

@diegolealco
Copy link

From Ubuntu's documentation LTS Enablement Stacks, the recommended way to install a hardware enablement stack is as follows:

sudo apt install --install-recommends linux-generic-hwe-18.04

I am not convinced that this is a proper solution. Either the kernel developers introduced a necessary change, a bug with an update, or a piece of software (fzf in this case) is using a feature in perhaps the wrong way; remember that kernel developers are very anal when it comes to not breaking userspace.

@ianchanning
Copy link

ianchanning commented Feb 16, 2019

@nzxcr no the hardware enablement isn't a proper solution. There's a fix in the kernel, it just needs verification on 18.04. See @junegunn 's comment. But if it's not verified by testers by Monday they'll drop the bug fix.

@ianchanning
Copy link

ianchanning commented Feb 18, 2019

I've confirmed that:

  1. If I remove my use of fd fix then I get the error
  2. If I turn on proposed releases (in Software & Updates > Developer Options), do an update to 4.15.0-46-generic and then restart I no longer get the error
uname -a
Linux ICT0115123 4.15.0-46-generic #49-Ubuntu SMP Wed Feb 6 09:33:07 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

I've also just spotted that in @junegunn 's comment the status of the bug has been updated to verified. 🎉

@nickgronow
Copy link

Updating to the latest on Ubuntu 18.10 fixed it.

@mrvon
Copy link

mrvon commented Feb 19, 2019

On ubuntu 16.04, I downgrade to linux-image-4.4.0-141 sloved this problem.

sudo apt remove linux-image-4.4.0-142-generic linux-headers-4.4.0-142

@marcinpraczko
Copy link

Is there any fix on ubuntu 16.04 for upgrade kernel - not downgrade?

@ianchanning
Copy link

ianchanning commented Feb 21, 2019

@marcinpraczko Yes - see @junegunn 's comment. It'll probably still be in pre-release. You can turn on proposed releases in the Software and Updates > Developer Options (tab)

@moonwater
Copy link

I have the same issue on ubuntu
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic

$ uname -r
4.15.0-45-generic

I got "Failed to read /dev/tty" in bash.
and then I install a shell of fish to run fzf, it works for the first time. and it failed with the same error message for the second time.
I don't know why, everything works fine in tmux.

And I think it might cause more problem using specific version of kernel by:

sudo apt install linux-image-generic-hwe-18.04 linux-headers-generic-hwe-18.04

@rtucek
Copy link

rtucek commented Mar 5, 2019

I upgraded to the recently released kernel 4.15.0-46-generic on Ubuntu 18.04 and approve that the regression has been fixed.

edit:
As a sidenote - I haven't used the HWE kernel stack just patiently waited for the fix to be released.

@pgebheim
Copy link

pgebheim commented Mar 6, 2019

I as well can confirm that upgrading to 4.15.0-46 fixes this regression.

@daveyarwood
Copy link

daveyarwood commented Mar 7, 2019

I just upgraded my Linux kernel to 4.15.0-46 and the vim-fzf issue is fixed for me, but only if I run vim with SHELL set to bash (i.e. SHELL=bash vim path/to/file.txt)

I use fish shell, so my SHELL is ordinarily set to /usr/bin/fish.

When I run vim without setting SHELL in bash, I still see the "Failed to read /dev/tty" message when I run :FZF, and I get the following error message:

Error running ( /usr/bin/fish '/tmp/user/1000/nvim8K9mNu/11' )|'/home/dave/.fzf/bin/fzf'  '--multi' '--prompt' '~/.dotfiles/' --expect=ctrl-v,ctrl-x,ctrl-t --no-height > /tmp/user/1000/nvim8K9mNu/10

Is there some way that I can have fzf use bash instead of fish? Some configuration for vim-fzf, maybe? As a workaround, I could alter my vim alias to be SHELL=bash nvim, but that's a bit clunky.

EDIT: Worth noting: I have set shell=bash in my vimrc, so perhaps vim-fzf could recognize that and use bash instead of fish?

@dnmfarrell
Copy link

I was bitten by this on 14.04 4.4.0-142. Downgrading to 4.4.0-141 resolved the issue

@butla
Copy link

butla commented Mar 14, 2019

Was resolved with patches to the kernel of 18.04. The only version still waiting for the patch is Xenial (looking at the bug report).

Actually, shouldn't this issue be closed? It's just waiting on that Ubuntu fix to go in right now.

@daveyarwood
Copy link

I'm still seeing this issue appear sporadically for me. It seems to happen if I use vim-fzf twice in quick succession, i.e.

  1. Run :FZF, fuzzy find my way to a file, select the file.
  2. Immediately run :FZF again.

I'm on Ubuntu 16.04, FWIW.

@piroux
Copy link

piroux commented Mar 17, 2019

For Ubuntu 14.04 with a 4.4.0 Kernel, the package 4.4.0-143.169, released last Friday, fixes the bug.

This bug was fixed in the package linux - 4.4.0-143.169
linux (4.4.0-143.169) xenial; urgency=medium

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1814647

@njohnson7
Copy link

still have same problem on Ubuntu kernel 5.3.0-20-generic and neovim v0.5.0-dev

@PhilippOrtnerUp2Go
Copy link

I also still have it.
uname -a
5.3.11-050311-generic SMP Tue Nov 12 21:37:23 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

@75re
Copy link

75re commented Mar 24, 2020

I also still have it.
$ uname -a
Linux jimmy-OptiPlex-3020 4.15.0-45-generic #48~16.04.1-Ubuntu SMP Tue Jan 29 18:03:48 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

@ofrades ofrades mentioned this issue Jul 19, 2020
10 tasks
@ofrades
Copy link

ofrades commented Jul 19, 2020

I have the same issue with Ubuntu 20.04 LTS

Error running cd '/home/ofrades' && cat '/tmp/vp6RsJV/12'LINES=70 COLUMNS=240 'home/ofrades/.vim/plugged/fzf/bin/fzf-tmux' -p90%,60% -- '--color=bg+:236,bg:237,boders:240,spinner:108,hl:65,fg:252,header:65,info:143,pointer:161,marker:168,fg+:252,prompt:110,hl+:108' --ansi --expect ctrl-x --tiebreak+index --header-lines 1 -x --prompt "Commands> " -2,3,2..3 -d > /tmp/vp6RsJV/11

Update: I actually have it working
By updating

if exists('$TMUX')
  let g:fzf_layout = { 'tmux': '-p90%,60%' }
else
  let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
endif

to only this line
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }

@junegunn
Copy link
Owner

You need tmux 3.2 or above to use popups.

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

Successfully merging a pull request may close this issue.