wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.83k stars 266 forks source link

packer.nvim sources directories named .vim despite rtp setting #626

Open strager opened 2 years ago

strager commented 2 years ago

Summary

If a Git repository has a plugin directory, and within it is a directory with a .vim suffix, :PackerSync tries to :source the directory. This happens even when using the rtp setting. It looks like rtp is ignored by :PackerSync's :sourceing.

Example plugin repo demonstrating the issue: https://github.com/strager/packer-nvim-bug

Steps to reproduce

Register this repo with packer.nvim with an runtimepath of plugin/myplugin.vim: https://github.com/strager/packer-nvim-bug

Then, restart Neovim and run :PackerSync.

Actual behaviour

Installation reports an error:

               packer.nvim - finished in 1.736s
 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 ✗ Failed to install strager/packer-nvim-bug
  Commits:
    4a2d3c2 Demonstrate packer.nvim bug (15 minutes ago)

 Press 'q' to quit
 Press '<CR>' to show more info
 Press 'd' to show the diff
 Press 'r' to revert an update

:messages shows more details:

[packer.nvim] [WARN  17:29:34] clean.lua:79: Cleaning cancelled!
[packer.nvim] [ERROR 17:29:35] async.lua:20: Error in coroutine: ...ack/packer/start/packer.nvim/lua
/packer/plugin_utils.lua:204: Vim(source):E484: Can't open file /home/strager/.local/share/nvim/site
/pack/packer/start/packer-nvim-bug/plugin/myplugin.vim

However, the plugin does seem to be installed. Running :call myplugin#hello() prints hello world.

Expected behaviour

Installation succeeds without error. Running :call myplugin#hello() prints hello world.

packer files

Plugin specification file(s) ``` vim.cmd [[packadd packer.nvim]] return require('packer').startup(function() use 'w0rp/ale' use {'strager/packer-nvim-bug', rtp = 'plugin/myplugin.vim'} end) ```
packer log file ``` [WARN Wed 29 Sep 2021 10:46:41 PM PDT 3.0038481396473e+14] .../site/pack/packer/start/packer.nvim/lua/packer/clean.lua:79: Cleaning cancelled! [WARN Wed 29 Sep 2021 10:48:15 PM PDT 3.0047908623805e+14] .../site/pack/packer/start/packer.nvim/lua/packer/clean.lua:79: Cleaning cancelled! [ERROR Wed 29 Sep 2021 10:48:18 PM PDT 3.0048180506109e+14] .../site/pack/packer/start/packer.nvim/lua/packer/async.lua:20: Error in coroutine: ...ack/packer/start/packer.nvim/lua/packer/plugin_utils.lua:204: Vim(source):E484: Can't open file /home/strager/.local/share/nvim/site/pack/packer/start/quick-lint-js/plugin/vim/quick-lint-js.vim [WARN Wed 29 Sep 2021 10:48:52 PM PDT 3.0051635821834e+14] ...ite/pack/packer/start/packer.nvim/lua/packer/display.lua:613: No plugin selected! [WARN Wed 29 Sep 2021 10:52:04 PM PDT 3.0070786254814e+14] .../site/pack/packer/start/packer.nvim/lua/packer/clean.lua:79: Cleaning cancelled! [ERROR Wed 29 Sep 2021 10:52:07 PM PDT 3.0071082514389e+14] .../site/pack/packer/start/packer.nvim/lua/packer/async.lua:20: Error in coroutine: ...ack/packer/start/packer.nvim/lua/packer/plugin_utils.lua:204: Vim(source):E484: Can't open file /home/strager/.local/share/nvim/site/pack/packer/start/taco/plugin/vim/quick-lint-js.vim [WARN Wed 29 Sep 2021 10:59:33 PM PDT 3.0115706422367e+14] .../site/pack/packer/start/packer.nvim/lua/packer/clean.lua:79: Cleaning cancelled! [ERROR Wed 29 Sep 2021 10:59:35 PM PDT 3.0115942775217e+14] .../site/pack/packer/start/packer.nvim/lua/packer/async.lua:20: Error in coroutine: ...ack/packer/start/packer.nvim/lua/packer/plugin_utils.lua:204: Vim(source):E484: Can't open file /home/strager/.local/share/nvim/site/pack/packer/start/quick-lint-js/plugin/vim/quick-lint-js.vim [WARN Thu 30 Sep 2021 05:16:37 PM PDT 3.0277473163035e+14] .../site/pack/packer/start/packer.nvim/lua/packer/clean.lua:79: Cleaning cancelled! [WARN Thu 30 Sep 2021 05:17:34 PM PDT 3.02831491865e+14] .../site/pack/packer/start/packer.nvim/lua/packer/clean.lua:79: Cleaning cancelled! [WARN Thu 30 Sep 2021 05:18:37 PM PDT 3.0289436434014e+14] .../site/pack/packer/start/packer.nvim/lua/packer/clean.lua:79: Cleaning cancelled! [ERROR Thu 30 Sep 2021 05:18:37 PM PDT 3.0289439672718e+14] .../site/pack/packer/start/packer.nvim/lua/packer/async.lua:20: Error in coroutine: ...ack/packer/start/packer.nvim/lua/packer/plugin_utils.lua:204: Vim(source):E484: Can't open file /home/strager/.local/share/nvim/site/pack/packer/start/packer-nvim-bug/plugin/myplugin.vim [WARN Thu 30 Sep 2021 05:29:34 PM PDT 3.0355158242034e+14] .../site/pack/packer/start/packer.nvim/lua/packer/clean.lua:79: Cleaning cancelled! [ERROR Thu 30 Sep 2021 05:29:35 PM PDT 3.0355228077935e+14] .../site/pack/packer/start/packer.nvim/lua/packer/async.lua:20: Error in coroutine: ...ack/packer/start/packer.nvim/lua/packer/plugin_utils.lua:204: Vim(source):E484: Can't open file /home/strager/.local/share/nvim/site/pack/packer/start/packer-nvim-bug/plugin/myplugin.vim ```
packer compiled file Where is `packer_compiled.vim`? I don't see it in `~/.config/nvim` or in `~/.local/share/nvim`.
akinsho commented 2 years ago

Hi @strager,

The rtp option is only set inside packers compiled file which by default is only sourced after your nvim config is loaded so it basically doesn't take effect till runtime. I work around this by sourcing my packer compiled file manually whilst my init.lua is being loaded.

There is a plan to refactor packer so this is less of an issue but unfortunately there aren't enough contributors/time for the available contributors to implement it yet, hopefully this won't be an issue in the future

wbthomason commented 2 years ago

I'll note that while @akinsho is correct about when the rtp setting is sourced (and its as-soon-as-I-have-time solution...), we could partially fix this bug by checking if paths are files or directories before we try to source them.