nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.66k stars 828 forks source link

rg and fd not found even though the binaries are installed #1490

Closed pdindorf closed 2 years ago

pdindorf commented 2 years ago

Description

Telescope live_grep doesn't work even though all dependencies seem to be satisfied. When I ran the checkhealth command I get the following:

health#telescope#check

Checking for required plugins

Checking external dependencies

However both ripgrep and fd are installed and accessible from bash: ~> which fd && which rg /usr/bin/fd /usr/bin/rg

In the telescope.log I can see the following stacktrace: [WARN Tue 23 Nov 2021 11:24:11 PM CET] ...ta/nvim/plugged/telescope.nvim/lua/telescope/pickers.lua:434: Finder failed with msg: ...vim/data/nvim/plugged/telescope.nvim/lua/telescope/.lua:287: rg: Executable not found stack traceback: ...vim/data/nvim/plugged/telescope.nvim/lua/telescope/.lua:287: in function 'convertopts' ...vim/data/nvim/plugged/telescope.nvim/lua/telescope/.lua:17: in function 'new' ...vim/data/nvim/plugged/telescope.nvim/lua/telescope/_.lua:59: in function 'spawn' ...elescope.nvim/lua/telescope/finders/async_job_finder.lua:49: in function 'finder' ...ta/nvim/plugged/telescope.nvim/lua/telescope/pickers.lua:430: in function <...ta/nvim/plugged/telescope.nvim/lua/telescope/pickers.lua:429> [C]: in function 'pcall' ...ta/nvim/plugged/telescope.nvim/lua/telescope/pickers.lua:429: in function <...ta/nvim/plugged/telescope.nvim/lua/telescope/pickers.lua:377>

I have neovim installed as a flatpak. Telescope + it's dependencies (Treesitter, nvim-lspconfig, devicons, plenary) installed via vim-plug. Ripgrep and fd has been installed from official openSUSE repositories:

Information for package ripgrep:

Repository : Main Repository Name : ripgrep Version : 12.1.1-bp153.1.14 Arch : x86_64 Vendor : openSUSE Installed Size : 5.0 MiB Installed : Yes Status : up-to-date Source package : ripgrep-12.1.1-bp153.1.14.src Summary : A search tool that combines ag with grep Description : ripgrep is a line oriented search tool that combines the usability of The Silver Searcher (similar to ack) with the raw speed of GNU grep. ripgrep works by recursively searching your current directory for a regex pattern.

Information for package fd:

Repository : Main Repository Name : fd Version : 8.1.1-bp153.1.14 Arch : x86_64 Vendor : openSUSE Installed Size : 3.1 MiB Installed : Yes Status : up-to-date Source package : fd-8.1.1-bp153.1.14.src Summary : An alternative to the "find" utility Description : fd is an alternative to GNU find. It features:

* Colorized terminal output (similar to ls).
* The search is case-insensitive by default. It switches to
  case-sensitive if the pattern contains an uppercase character.
* By default, ignores patterns from .gitignore, and ignores hidden
  directories and files.
* Supports regular expressions and Unicode awareness.
* A parallel execution similar to GNU Parallel is available.

Neovim version

NVIM v0.5.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/run/build/neovim/_flatpak_build/config -I/run/build/neovim/src -I/app/include -I/usr/include -I/run/build/neovim/_flatpak_build/src/nvim/auto -I/run/build/neovim/_flatpak_build/include
Compiled by buildbot@cncf-x86-2.flathub.org

Features: +acl +iconv +tui
See ":help feature-compile"

Operating system and version

openSUSE Leap 15.3

checkhealth telescope

health#telescope#check
========================================================================
## Checking for required plugins
  - OK: plenary installed.
  - OK: nvim-treesitter installed.

## Checking external dependencies
  - ERROR: rg: not found. `live-grep` finder will not function without [BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep) installed.
  - WARNING: fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities

Steps to reproduce

  1. Install neovim from flathub: sudo flatpak remote-add --if-not-exists flathub https://flathub.org/~hub.flatpakrepo sudo flatpak install neovim
  2. Install ripgrep and fd via zypper (openSUSE Leap 15.3): sudo zypper in ripgrep fd
  3. Run neovim from flatpak with minimal config: flatpak run io.neovim.nvim -u <PATH_TO_CONFIG>
  4. Run :PlugInstall and once everything got installed run :Telescope live_grep

Expected behavior

Popup telescope window with working ripgrep functionality

Actual behavior

I get a popup window but when I type a text to search I get absolutely no results: nvim_live_grep

When I run rg from cli from the very same directory I get the results: ripgrep_from_cli

Minimal config

runtime ./plug.vim
filetype plugin indent on

if has("nvim")
    let g:plug_home = stdpath('data') . '/plugged'
endif

call plug#begin()

if has("nvim")
    Plug 'neovim/nvim-lspconfig'
    Plug 'nvim-treesitter/nvim-treesitter'
    Plug 'kyazdani42/nvim-web-devicons'
    Plug 'nvim-lua/plenary.nvim'
    Plug 'nvim-telescope/telescope.nvim'
endif
call plug#end()
fdschmidt93 commented 2 years ago

This sounds like path variables between flatpack and OpenSuse's package manager don't play nicely together.

Quick test: open standard vim (or neovim), whatever you can install from your systems' package manager and run this command echo executable("rg"), which should return 1. That would be a strong indicator for my hypothesis.

I'm honestly not entirely sure how this would be fixed as I'm unfamiliar with flatpack. Quick googling https://docs.flatpak.org/en/latest/sandbox-permissions.html confirms my hunch that any flatpak application is entirely sandboxed from the OS.

See also this reddit post, so I guess it might work when launching nvim with flatpak-spawn --host.

In any case, this is not a telescope but rather a flatpak issue. I'm happy to try and help here on the issue further if you have more questions, but closing this already for the aforementioned reason. Good luck :)

pdindorf commented 2 years ago

Thank you! You were absolutely right - flatpak completely sandboxes application from other binaries and that's what technically makes it secure.

I've manged to fix my issue by copying fd and rg binaries from /usr/bin to /var/lib/flatpak/app/io.neovim.nvim/x86_64/stable/active/files/bin.

Unfortunately symlinks are not visible for flatpak apps and hard links were a no-go in my case as /var and /usr are on different partitions on my system. Fortunately neovim has :terminal feature which made troubleshooting of this issue much much easier. Thank you!!!