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.89k stars 264 forks source link

Module packer.luarocks not found on mac osx 13.3 #1228

Open rahulkp220 opened 1 year ago

rahulkp220 commented 1 year ago

Unable to run PackerSync or PackerInstall commands on mac.

Steps to reproduce

Cloned repo to the right path

│~/.config/nvim
└─> ls -lrt ~/.local/share/nvim/site/pack/packer/start/packer.nvim
total 120
-rw-r--r--  1 user  staff    710 Apr 10 15:33 Dockerfile
-rw-r--r--  1 user  staff   1069 Apr 10 15:33 LICENSE
-rw-r--r--  1 user  staff    328 Apr 10 15:33 Makefile
-rw-r--r--  1 user  staff  33128 Apr 10 15:33 README.md
drwxr-xr-x  3 user  staff     96 Apr 10 15:33 doc
drwxr-xr-x  4 user  staff    128 Apr 10 15:33 lua
-rw-r--r--  1 user  staff     10 Apr 10 15:33 selene.toml
-rw-r--r--  1 user  staff    100 Apr 10 15:33 stylua.toml
drwxr-xr-x  9 user  staff    288 Apr 10 15:33 tests
-rw-r--r--  1 user  staff    610 Apr 10 15:33 vim.toml

Used a simple init.lua using the https://github.com/nvim-lua/kickstart.nvim. Created a simple lua/ directory and create a file named installer.lua, paste packer configs.

Content of installer.lua

return require('packer').startup(function(use)
    use 'wbthomason/packer.nvim'
end)

File structure of ~/.config/nvim

┌───────────────────>
│~/.config/nvim
└─> tree .
.
├── init.lua
├── lazy-lock.json
└── lua
    └── installer.lua

1 directory, 3 files

Actual behaviour

E5108: Error executing lua ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:110: module 'packer.luarocks' not foun
d:
        no field package.preload['packer.luarocks']
cache_loader: module packer.luarocks not found
cache_loader_lib: module packer.luarocks not found
        no file './packer/luarocks.lua'
        no file '/opt/homebrew/share/luajit-2.1.0-beta3/packer/luarocks.lua'
        no file '/usr/local/share/lua/5.1/packer/luarocks.lua'
        no file '/usr/local/share/lua/5.1/packer/luarocks/init.lua'
        no file '/opt/homebrew/share/lua/5.1/packer/luarocks.lua'
        no file '/opt/homebrew/share/lua/5.1/packer/luarocks/init.lua'
        no file './packer/luarocks.so'
        no file '/usr/local/lib/lua/5.1/packer/luarocks.so'
        no file '/opt/homebrew/lib/lua/5.1/packer/luarocks.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './packer.so'
        no file '/usr/local/lib/lua/5.1/packer.so'
        no file '/opt/homebrew/lib/lua/5.1/packer.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:110: in function 'require_and_configure'
        ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:401: in function 'install'
        [string ":lua"]:1: in main chunk
misku commented 1 year ago

Same problem here

Error detected while processing BufWritePost Autocommands for "plugins.lua":
E5108: Error executing lua ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:110: module 'packer.luarocks' not found:
        no field package.preload['packer.luarocks']
cache_loader: module packer.luarocks not found
cache_loader_lib: module packer.luarocks not found
        no file './packer/luarocks.lua'
        no file '/opt/homebrew/share/luajit-2.1.0-beta3/packer/luarocks.lua'
        no file '/usr/local/share/lua/5.1/packer/luarocks.lua'
        no file '/usr/local/share/lua/5.1/packer/luarocks/init.lua'
        no file '/opt/homebrew/share/lua/5.1/packer/luarocks.lua'
        no file '/opt/homebrew/share/lua/5.1/packer/luarocks/init.lua'
        no file './packer/luarocks.so'
        no file '/usr/local/lib/lua/5.1/packer/luarocks.so'
        no file '/opt/homebrew/lib/lua/5.1/packer/luarocks.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './packer.so'
        no file '/usr/local/lib/lua/5.1/packer.so'
        no file '/opt/homebrew/lib/lua/5.1/packer.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:110: in function 'require_and_configure'
        ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:576: in function 'sync'
        [string ":lua"]:1: in main chunk
misku commented 1 year ago

The problem is that neovim actually sticks to lua 5.1 for different reasons.

The error most likely happens due to brew install luarocks being built with lua newer than 5.1. Even if you have lua@5.1 installed with brew, installing luarocks with the mentioned command will install the newest version of lua anyway.

I worked around it by compiling luarocks manually with lua 5.1 headers from brew. This worked for me:

$ brew install lua@5.1
$ curl -R -O https://luarocks.github.io/luarocks/releases/luarocks-3.9.2.tar.gz
$ tar -zxf luarocks-3.9.2.tar.gz
$ cd luarocks-3.9.2.tar.gz
$ ./configure --with-lua-include="/opt/homebrew/Cellar/lua@5.1/5.1.5_8/include/lua5.1"
$ make && make install
$ ln -s /usr/local/share/lua /opt/homebrew/share/