Neovim-from-scratch icon indicating copy to clipboard operation
Neovim-from-scratch copied to clipboard

module 'user.options' not found

Open tillydray opened this issue 2 years ago • 7 comments

I get an error when running nvim from any directory other than ~/.config/nvim, even if I run it from ~/.config/nvim/user I get this error. Any idea why? I removed ~/.local/share/nvim before setting up your config. I have also done rm -rf ~/.config/nvim just to be sure there isn't anything leftover from my old config. I do have files in ~/.vim but I can't imagine that's effecting things.

I'm not sure if it's related to https://github.com/LunarVim/Neovim-from-scratch/issues/26.

Output of `cd ~/.config && tree nvim`, proving user/options.lua exists:
nvim
├── init.lua
├── plugin
│   └── packer_compiled.lua
└── user
    ├── alpha.lua
    ├── autocommands.lua
    ├── autopairs.lua
    ├── bufferline.lua
    ├── cmp.lua
    ├── colorscheme.lua
    ├── comment.lua
    ├── gitsigns.lua
    ├── impatient.lua
    ├── indentline.lua
    ├── keymaps.lua
    ├── lsp
    │   ├── handlers.lua
    │   ├── init.lua
    │   ├── lsp-installer.lua
    │   ├── null-ls.lua
    │   └── settings
    │       ├── jsonls.lua
    │       └── sumneko_lua.lua
    ├── lualine.lua
    ├── nvim-tree.lua
    ├── options.lua
    ├── plugins.lua
    ├── project.lua
    ├── telescope.lua
    ├── treesitter.lua
    └── whichkey.lua

4 directories, 27 files
Entire error:
Error detected while processing /redacted/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /redacted/.config/nvim/init.lua:1: module 'user.options' not found:
        no field package.preload['user.options']
        no file './user/options.lua'
        no file '/usr/local/Cellar/luajit-openresty/2.1-20220310/share/luajit-2.1.0-beta3/user/options.lua'
        no file '/usr/local/share/lua/5.1/user/options.lua'
        no file '/usr/local/share/lua/5.1/user/options/init.lua'
        no file '/usr/local/Cellar/luajit-openresty/2.1-20220310/share/lua/5.1/user/options.lua'
        no file '/usr/local/Cellar/luajit-openresty/2.1-20220310/share/lua/5.1/user/options/init.lua'
        no file './user/options.so'
        no file '/usr/local/lib/lua/5.1/user/options.so'
        no file '/usr/local/Cellar/luajit-openresty/2.1-20220310/lib/lua/5.1/user/options.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './user.so'
        no file '/usr/local/lib/lua/5.1/user.so'
        no file '/usr/local/Cellar/luajit-openresty/2.1-20220310/lib/lua/5.1/user.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        /redacted/.config/nvim/init.lua:1: in main chunk

tillydray avatar Apr 03 '22 21:04 tillydray

I get an error when running nvim from any directory other than ~/.config/nvim, even if I run it from ~/.config/nvim/user I get this error. Any idea why? I removed ~/.local/share/nvim before setting up your config. I have also done rm -rf ~/.config/nvim just to be sure there isn't anything leftover from my old config. I do have files in ~/.vim but I can't imagine that's effecting things.

I'm not sure if it's related to #26.

Output of cd ~/.config && tree nvim, proving user/options.lua exists:

nvim
├── init.lua
├── plugin
│   └── packer_compiled.lua
└── user
    ├── alpha.lua
    ├── autocommands.lua
    ├── autopairs.lua
    ├── bufferline.lua
    ├── cmp.lua
    ├── colorscheme.lua
    ├── comment.lua
    ├── gitsigns.lua
    ├── impatient.lua
    ├── indentline.lua
    ├── keymaps.lua
    ├── lsp
    │   ├── handlers.lua
    │   ├── init.lua
    │   ├── lsp-installer.lua
    │   ├── null-ls.lua
    │   └── settings
    │       ├── jsonls.lua
    │       └── sumneko_lua.lua
    ├── lualine.lua
    ├── nvim-tree.lua
    ├── options.lua
    ├── plugins.lua
    ├── project.lua
    ├── telescope.lua
    ├── treesitter.lua
    └── whichkey.lua

4 directories, 27 files

Entire error:

Error detected while processing /redacted/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /redacted/.config/nvim/init.lua:1: module 'user.options' not found:
        no field package.preload['user.options']
        no file './user/options.lua'
        no file '/usr/local/Cellar/luajit-openresty/2.1-20220310/share/luajit-2.1.0-beta3/user/options.lua'
        no file '/usr/local/share/lua/5.1/user/options.lua'
        no file '/usr/local/share/lua/5.1/user/options/init.lua'
        no file '/usr/local/Cellar/luajit-openresty/2.1-20220310/share/lua/5.1/user/options.lua'
        no file '/usr/local/Cellar/luajit-openresty/2.1-20220310/share/lua/5.1/user/options/init.lua'
        no file './user/options.so'
        no file '/usr/local/lib/lua/5.1/user/options.so'
        no file '/usr/local/Cellar/luajit-openresty/2.1-20220310/lib/lua/5.1/user/options.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './user.so'
        no file '/usr/local/lib/lua/5.1/user.so'
        no file '/usr/local/Cellar/luajit-openresty/2.1-20220310/lib/lua/5.1/user.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        /redacted/.config/nvim/init.lua:1: in main chunk

mb related to #106

Nojpg avatar Apr 04 '22 15:04 Nojpg

mb related to https://github.com/LunarVim/Neovim-from-scratch/issues/106

Thanks for the reply, but I'm not sure how they are related? I pasted the lua.lua file from the linked issue into ~/.config/nvim/ftplugin/lua.lua but am getting the same error as before

tillydray avatar Apr 07 '22 21:04 tillydray

I started nvim with nvim -V and got this output at the very beginning

chdir(/Users/redacted)                                                                                          
chdir(/etc/xdg/nvim)                                                                                              
chdir(/Users/redacted)                                                                                             
could not source "/etc/xdg/nvim/sysinit.vim"                                                                    
chdir(/Users/redacted)                                                                                        
chdir(/usr/local/Cellar/neovim/0.6.1/share/nvim)                                                             
chdir(/Users/redacted)                                                                                               
could not source "$VIM/sysinit.vim"                                                                                          
chdir(/Users/redacted)                                                                                          
chdir(/Users/redacted/.config/nvim)                                                                           
chdir(/Users/redacted)                                                                                               
sourcing "/Users/redacted/.config/nvim/init.lua"                                                                    
Error detected while processing /Users/redacted/.config/nvim/init.lua:                                             
E5113: Error while calling lua chunk: /Users/redacted/.config/nvim/init.lua:6: module 'user.options' not found:

I assume chdir changes the directory. So right before it sources init.lua, it does chdir(/Users/redacted). I think that's a problem? I did cp -r ~/.config/nvim ~ to copy all my config into my home dir and then when I open nvim from my home directory, I get no errors. However if I open it from any directory other than home or ~/.config/nvim, I get errors.

Maybe unrelated, but it seems odd and not good that it's doing chdir so much. It does it a bunch more after that error, while doing other things.

tillydray avatar Apr 07 '22 23:04 tillydray

I encountered the same problem. I used docker as a workaround. see: https://github.com/crokobit/Neovim-from-scratch/pull/1/files But there are other issues. asking for help now. see: https://github.com/LunarVim/Neovim-from-scratch/issues/110

crokobit avatar Apr 10 '22 09:04 crokobit

So my idea this morning is to do something like

local workingDir = vim.cmd(getcwd())
vim.cmd('cd ~/.config/nvim')

require "user.options"
-- etc

vim.cmd(cd workingDir)

However I get E5113: Error while calling lua chunk: redacted/.config/nvim/init.lua:8: attempt to call global 'getcwd' (a nil value) 😕 When I do :getcwd() from either nvim or vim I get E492: Not an editor command: getcwd()

tillydray avatar Apr 18 '22 13:04 tillydray

I ran into this same issue - it looks like your user directory needs to be within a lua directory ie:

~/.config/nvim/lua/user

AndyHeasman avatar May 05 '22 19:05 AndyHeasman

In your init.lua you you're calling the module as require "user.options". This will only work if you've structure like .config/lua/user/options.lua .

You can also call the module as: require "lua.user.options.lua"

himanshugoswamiii avatar May 06 '22 22:05 himanshugoswamiii