Telescope.nvim does not find fzf

Hello everyoneI know this doesn’t really fit in the NixOS forum but this problem only appears on NixOS (I tried it on a Fedora too and it worked).

So I have the neovim plugin telescope.nvim (installed via Lazy.nvim) and it uses telescope-fzf-native.nvim.

Problem

When I start Neovim I get following error:

Here as Text:

Failed to run `config` for telescope.nvim                                                                                                                                                                                    
                                                                                                                                                                                                                             
...m/lazy/telescope.nvim/lua/telescope/_extensions/init.lua:10: 'fzf' extension doesn't exist or isn't installed: ...hare/nvim/lazy/telescope-fzf-native.nvim/lua/fzf_lib.lua:11: /home/me/.local/share/nvim/lazy/telesc
ope-fzf-native.nvim/lua/../build/libfzf.so: cannot open shared object file: No such file or directory                                                                                                                        
                                                                                                                                                                                                                             
# stacktrace:                                                                                                                                                                                                                
  - /telescope.nvim/lua/telescope/_extensions/init.lua:10 _in_ **load_extension**                                                                                                                                            
  - /telescope.nvim/lua/telescope/_extensions/init.lua:62 _in_ **load_extension**                                                                                                                                            
  - ~/.config/nvim/lua/plugins/navigation/telescope.lua:27 _in_ **config**                                                                                                                                                   
  - ~/.config/nvim/lua/config/lazy.lua:28                                                                                                                                                                                    
  - ~/.config/nvim/lua/config/init.lua:3                                                                                                                                                                                     
  - ~/dotfiles/.config/nvim/init.lua:1  

When I use telesecope without the fzf-native plugin and install it instead in my configuration.nix it works fine.

Here is my telescope config:

return {
  "nvim-telescope/telescope.nvim",
  branch = "0.1.x",
  dependencies = {
    "nvim-lua/plenary.nvim",
    { "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
    "nvim-tree/nvim-web-devicons",
    "folke/todo-comments.nvim",
  },
  config = function()
    local telescope = require("telescope")
    local actions = require("telescope.actions")


    telescope.setup({
      defaults = {
        path_display = { "smart" },
        mappings = {
          i = {
            ["<C-k>"] = actions.move_selection_previous, -- move to prev result
            ["<C-j>"] = actions.move_selection_next, -- move to next result
          },
        },
      },
    })

    telescope.load_extension("fzf")

    -- set keymaps
    local keymap = vim.keymap -- for conciseness

    keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Fuzzy find files in cwd" })
    keymap.set("n", "<leader>fr", "<cmd>Telescope oldfiles<cr>", { desc = "Fuzzy find recent files" })
    keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>", { desc = "Find string in cwd" })
    keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>", { desc = "Find string under cursor in cwd" })
    keymap.set("n", "<leader>ft", "<cmd>TodoTelescope<cr>", { desc = "Find todos" })
  end,
}

Does anyone know what the problem is?

Please I need help. I am so frustrated.

Have you installed the vimPlugins.telescope-fzf-native-nvim plugin from nix pkgs?

Other thoughts: Using Lazy.nvim is possible with nix, but is not really the “nix” way of doing Neovim configs. If you require lazy.nvim, you might look at how others have used this. I have appreciated lazy.nvim on NixOS - Nixalted Website as a good intro to this.

This implies that the resulting binary after the linker step doesn’t point to the right directory, and on NixOS, the location of shared libraries is not going to be in /usr/lib or whatever. Hence downloading an arbitrary binary off the internet and running it on NixOS will generally not work. Hence the suggestion above to try to use the plugins as packaged in nixpkgs, and if it still doesn’t work, of course please report the issue.

I just tried it and it still shows the same error message

If you use the home-manager module and want to do things the lazy way, just add the dependencies to extraPckages:

programs.neovim = {
  enable = true;
  extraPackages = with pkgs; [
    gcc
    # build = "make/cmake"
    cmake
    gnumake
  ];
};

Then it will build correctly.

I already have those packages installed

Through extraPckages or system-wide? Because I think there is a difference there.

That said, if you want a Lazy-based config that will work in NixOS and other distros, you could check out lazy-nix-helper.nvim.

Through extraPckages or system-wide? Because I think there is a difference there.

I tried it with extraPackages and system-wide. Both didn’t work…

That said, if you want a Lazy-based config that will work in NixOS and other distros, you could check out lazy-nix-helper.nvim .

Does this mean I have to rewrite my entire config? Is there no simpler way? Can I pull my dotfiles from a remote git repo and just throw them in the correct folders? I know this is not the Nix way but I am currently too frustrated to rewrite my entire dotfiles…

That’s odd. This is what I’m using for my config and it’s working fine. Perhaps you should remove the plugin, do a Lazy clean then install it again.

No, you can totally use your existing config. Mine is based on kickstart-nvim, written in Lua and all plugins are installed by Lazy. Nix just installs the dependencies I need for the plugins using extraPackages.

I suggested this because supposedly all you have to do is change the Lazy configuration and it should just work. Perhaps I was wrong, though … Was it too complex to set up?

You don’t always have to do things the Nix way, really. Just do what’s easiest for you at the moment and slowly build up from there.

2 Likes

Thanks for all the information man. I really appreciate it!

1 Like