fzf: [Ubuntu] --preview error : Failed to read /dev/tty
- 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
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 58
- Comments: 70 (3 by maintainers)
Links to this issue
Commits related to this issue
- Do not use fzf preview because ubuntu bug breaks it https://github.com/junegunn/fzf/issues/1486#issuecomment-459091653 — committed to kthibodeaux/.dotfiles by kthibodeaux 5 years ago
- fzfが使えないことの一次対応(https://github.com/junegunn/fzf/issues/1486) — committed to tadashi-aikawa/owl-playbook by tadashi-aikawa 5 years ago
- fzfが使えないことの一次対応(https://github.com/junegunn/fzf/issues/1486) — committed to tadashi-aikawa/owl-playbook by tadashi-aikawa 5 years ago
- kubectx not working with fzf on ubuntu cause of ubuntu kernel bug -> https://github.com/junegunn/fzf/issues/1486 using fzf with -1 parameter is a workaround for this bug and also give auto select if l... — committed to emreodabas/kubectx by emreodabas 5 years ago
- Handling EAGAIN on with 2 retries for robustness Handles an anoying kernel bug and is a bit more robust in such a case. Handles #1486 — committed to jerdna-regeiz/fzf by jerdna-regeiz 5 years ago
- Fix fzf tty read error * Changes seem to fix "tty error" * See: https://github.com/junegunn/fzf/issues/1486 — committed to edloaa/dotfiles by edloaa 5 years ago
As a working fzf in vim is such an important part of my daily work I ended up rolling back the kernel
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
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:
“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.
I’ve no idea if this will work for other people, but I think I’ve found a workaround (plus it’s a good solution in general anyway).
My usage of FZF with <kbd>Ctrl</kbd> + <kbd>R</kbd> has always worked fine - so it’s not FZF that’s necessarily the problem but the command it’s calling. Today randomly I switched to using
fd
(https://github.com/sharkdp/fd) for my FZF search and FZF now seems to happily work even on4.15.0-45-generic
.Once you’ve installed
fd
you can try putting this in your.bashrc
, restart your terminal and see iffzf
works again:Interesting, I’m using neovim and was seeing the problem
Hey Ubuntu users (16.04 and 18.04), you can help Ubuntu team release the fix. See:
A likely culprit: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1813873
For those using Ubuntu a related fix has being released in kernel version 4.18.0-15.16, hopefully that will resolve this problem
http://changelogs.ubuntu.com/changelogs/pool/main/l/linux/linux_4.18.0-15.16/changelog
Not that I know what I’m doing but
sudo chmod 660 /dev/tty
solved what appeared to be a similar problem on my Ubuntu 16.04 4.15.0-1027-gcp machine.Was experiencing the issue in both nvim and using the cmdline (
bash -c "sleep 1; bash -c 'echo hello'" | fzf
) on kernel 4.15 I installed @shuhaowu packages, restarted, and both nvm and cmdline work.uname-r
is showing4.18.0-15-generic
which seems consistent with updating the kernel directly via @emont01 solution.With some trial and error, I’ve found that this can reliably reproduce the issue:
Kernel version updated to
4.15.0-45
but that didn’t help. Updated FZF to the latest. Still seeing the error randomly.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 previous4.15.0-43
kernel and the error does not happen.fixed by
I was running
4.15.0-45-generic
andfzf
was working with Bash, but was getting this error with Fish:However,
fzf
is now working after following @shuhaowu’s advice and installing:Although I’m not quite sure what this does, apart from possibly changing my kernel to a completely different version.
On ubuntu 16.04, I downgrade to linux-image-4.4.0-141 sloved this problem.
I’ve confirmed that:
fd
fix then I get the error4.15.0-46-generic
and then restart I no longer get the errorI’ve also just spotted that in @junegunn 's comment the status of the bug has been updated to verified. 🎉
The solution / workaround by @shuhaowu works for me too (after a reboot) in tmux under Ubuntu
18.04
- upgraded to kernel4.18.0-15-generic
. Did the trick for both inside of Vim and on Bash4.4.19
.Just updated ubuntu 18.04 to kernal 4.18.20 and fzf now works
@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.
The same error is on Ubuntu 16.04.
Doing
sudo chmod 600 /dev/tty
also breakstig
, which apparently expects666
as the file permission.For Ubuntu 14.04 with a
4.4.0
Kernel, the package4.4.0-143.169
, released last Friday, fixes the bug.https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1814647
From Ubuntu’s documentation LTS Enablement Stacks, the recommended way to install a hardware enablement stack is as follows:
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.
@nickgronow It appears that the fix was already released for Cosmic. See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1813873/comments/21
Simple fix is to read tty again. Maybe retries do not have to be normally, but in this case it solves the problem without going for an older kernel 😃 (see #1495)
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
I was bitten by this on 14.04
4.4.0-142
. Downgrading to4.4.0-141
resolved the issueI as well can confirm that upgrading to 4.15.0-46 fixes this regression.
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 chmod 660 /dev/tty
works for me too, but then ssh does not work for me 😆When I change it back to 666 (as it was), ssh works but fzf does not.
Update: This has been working for me the whole day so far.
The
bash -c "sleep 1; bash -c 'echo hello'" | fzf
will still give an error, but that seems unrelated. Perhaps that gave an error before this bug occurred as well.I had to bump the retries to 10 in @jerdna-regeiz’s workaround to make it consistently work on 4.15.0-45-generic.
Probably not something that should be integrated into junegunn:master, but a useful workaround until Ubuntu can push out an updated kernel.
With kernal
4.15.0-45
the problem appears to be worse for me. Simply runningfzf
in the terminal or in vim/neovim fails now. I had one successful attempt in about 20.@vhakulinen your findings are consistent with the ubuntu kernel bug linked above. It mentions:
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.After doing some research, every time I get
Failed to read /dev/tty
, this returnssyscall.EAGAIN
. ~This probably means that the operation needs to be tried again: https://stackoverflow.com/questions/4058368/what-does-eagain-mean~Confirmed that booting Ubuntu kernel
4.15.0-43
allows fzf to work properly. For now have uninstalled4.15.0-44
and am booting previous kernel.