nvim-telescope / telescope.nvim

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

Telescope silently fails if `fd` or `rg` are installed via snap #2081

Open TwoClocks opened 2 years ago

TwoClocks commented 2 years ago

Description

If you install fd or rg via snap (linux), find_files and live_grep are blank. The pickers pop up, but nothing is in them regardless of what is typed. CheckHealth shows green for both being installed and found.

Neovim version

NVIM v0.7.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -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/build/nvim/parts/nvim/build/build/config -I/build/nvim/parts/nvim/build/src -I/build/nvim/parts/nvim/build/.deps/usr/include -I/usr/include -I/build/nvim/parts/nvim/build/build/src/nvim/auto -I/build/nvim/parts/nvim/build/build/include
Compiled by root@lcy02-amd64-012

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

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Operating system and version

Ubuntu 20.04.4 LTS

Telescope version / branch / rev

0.1.0

checkhealth telescope

elescope: require("telescope.health").check()
========================================================================
## Checking for required plugins
  - OK: plenary installed.
  - OK: nvim-treesitter installed.

## Checking external dependencies
  - OK: rg: found ripgrep 11.0.2
  - OK: fd: found fd 7.4.0

## ===== Installed extensions =====

Steps to reproduce

un-intall rg and fd. re-install from snap.

Expected behavior

live_grep should work

Actual behavior

live_grep does not work. The picker comes up, but is blank.

Minimal config

any working telescope config.
Conni2461 commented 2 years ago

I have to test this in an ubuntu vm. I dont use snap. I have to come back to you in the next couple of days

TwoClocks commented 2 years ago

Both apps are in apt, but a slightly older version, so I'm fine. I've run into other problems w/ neovim and snap. Other plugins don't like node installed via snap. snap bins are weird simlinks. /usr/bin/rg/ links to /usr/bin/snap. Everyting snap installs links to /usr/bin/snap. If you can reproduce it and it's a hard fix you could just add a warning to the docs.

thomas-harmeyer commented 1 year ago

at the very least some kind of warning should be shown. This is a very hard problem to troubleshoot.

jamestrew commented 1 year ago

I think this is due to snap's confinement capabilities. I don't have a ubuntu machine myself but can someone with ubuntu and rg installed via snap try this and share the output?

local utils = require("telescope.utils")
vim.print(utils.get_os_command_output({ "rg", "--files" }, vim.uv.cwd()))

I can probably improve telescope's checkhealth command to catch accessibility issues due to snap packages maybe.

Ridhamz-nd commented 1 year ago

@jamestrew I was encountering the same issue when I installed rg using snap. installing with apt fixes the issue. Thanks for your help with this :) Out of curiosity, how did you find out that this was due to snap's confinement capabilities? Is this confinement dynamic (which could be the reason why it worked under bash but not under nvim)?

jamestrew commented 1 year ago

I don't remember how I heard of it. It was just in passing or something. I haven't really looked into much since either.

Is this confinement dynamic (which could be the reason why it worked under bash but not under nvim)?

I believe so

TwoClocks commented 1 year ago

Out of curiosity, how did you find out that this was due to snap's confinement capabilities?

I ran strace and looked for errors. Snap installs in a char_root'd like environment, so it doesn't have access to files/directories unless specifically granted to it (or installed as "classic" or "developer"). So you get a lot of PERMISSION_DENIED errors in the strace

Ridhamz-nd commented 1 year ago

I ran strace and looked for errors

Awesome! This'll be a good addition to my debugging arsenal. Thanks!