NTBBloodbath / cheovim

Neovim configuration switcher written in Lua. Inspired by chemacs.
GNU General Public License v2.0
332 stars 13 forks source link

"Error while calling lua chunk... attempt to concatenate a nil value" #17

Closed harmolipi closed 1 year ago

harmolipi commented 2 years ago

Hey, cheovim seems awesome. I'm just trying to get started with it, but no luck unfortunately. So far I followed the directions, moved my original config to ~/.config/nvim.bak, deleted the files I had running automatically to configure plugins, and then pulled cheovim into the ~/.config/nvim directory. But then when I try to nvim profiles.lua, before the file comes up, I get some errors:

Censoring all the bad reviews...
Error detected while processing /Users/nikobirbilis/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /Users/nikobirbilis/.config/nvim/lua/cheovim/loader.lua:172: attempt t
o concatenate a nil value
stack traceback:
        /Users/nikobirbilis/.config/nvim/lua/cheovim/loader.lua:172: in function 'create_plugin_manager_syml
inks'
        /Users/nikobirbilis/.config/nvim/lua/cheovim/loader.lua:388: in function 'create_plugin_symlink'
        /Users/nikobirbilis/.config/nvim/lua/cheovim.lua:19: in main chunk
        [C]: in function 'require'
        /Users/nikobirbilis/.config/nvim/init.lua:1: in main chunk
Press ENTER or type command to continue

and

Error executing luv callback:
/Users/nikobirbilis/.config/nvim/lua/cheovim/loader.lua:115: E5560: vimL function must not be called in a lu
a loop callback
stack traceback:
        [C]: in function '_stdpath'
        /Users/nikobirbilis/.config/nvim/lua/cheovim/loader.lua:115: in function </Users/nikobirbilis/.confi
g/nvim/lua/cheovim/loader.lua:112>
Press ENTER or type command to continue

Then the file comes up, and by default it's pointing "my_config" to "~/.config/nvim.bak" so I think that should already be working without configuring anything else... but alas, those errors open every time I open neovim and it's not able to pull any configurations in. Any idea what I'm doing wrong?

AndOrangutan commented 2 years ago

I am getting the same error.

Error detected while processing /home/vm/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /home/vm/.config/nvim/lua/cheovim/loader.lua:172: attempt to concatenate a nil value
stack traceback:
        [C]: in function 'require'
        /home/vm/.config/nvim/init.lua:1: in main chunk

This happens on startup after following the instructions in the README.md, including clearing out nvim's config folder and packers install location.

But after a bit of testing I tried setting preconfigure to its default value since the code causeing the issue seems to be related.

Error detected while processing /home/vm/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /home/vm/.config/nvim/lua/cheovim/loader.lua:276: attempt to call method 'closedir' (a nil value)
stack traceback:
        [C]: in function 'require'
        /home/vm/.config/nvim/init.lua:1: in main chunk
mac-hel commented 2 years ago

I get same errors. Tried same workaround as @AndOrangutan and encountered same second error (loader.lua:276)

tigorlazuardi commented 2 years ago

Since I do not know very well about luv and about the code base, treat this solution as a band aid at best.

Change this line in lua/cheovim/loader.lua:170

        local install_path = root_plugin_dir
            .. "/"
            .. profile_config.plugins
            .. "/"
            .. preconfigure_options[2]
            .. "/"
            .. (preconfigure_options[1] == "packer" and "packer.nvim" or "paq-nvim")

to this:

        local install_path = root_plugin_dir
            .. "/"
            .. profile_config.plugins
            .. "/"
            .. (preconfigure_options[2] or "start") -- this section now takes account when preconfigure has no opt or start value.
            .. "/"
            .. (preconfigure_options[1] == "packer" and "packer.nvim" or "paq-nvim")

And remove the close method in install_dir in line 276:

install_dir:closedir() -- remove this line

This probably caused by luv has no metatable method of closedir() for returned userdata of luv in vim 0.8.

Doing the above things resolve the errors for me. Though I have not tested the impact of ignoring any kind of closer methods on luv. But even then it will always be garbage collected sooner or later because there's nothing references it after cheovim finished loading, so it should be fine.

richardhttps commented 2 years ago

Was about to open an issue for the same error but a clean reinstall fixed it, this time leaving the plugins path alone. I initially wanted my profiles to have their own packer subfolders like this:

...
    nvchad = { "~/.config/nvim/nvchad", {
            plugins = "packer/nvchad",
     ...

But leaving it to just "packer" solved it for me.

harmolipi commented 2 years ago

Was about to open an issue for the same error but a clean reinstall fixed it, this time leaving the plugins path alone. I initially wanted my profiles to have their own packer subfolders like this:

...
  nvchad = { "~/.config/nvim/nvchad", {
          plugins = "packer/nvchad",
     ...

But leaving it to just "packer" solved it for me.

Good to hear - what exactly did you reinstall... would just starting with a totally blank ~/.config/nvim directory do it, or is there more you need to get rid of to do a fully clean install? Thought I did that but I can give it another shot. Otherwise I'll try what @tigorlazuardi suggested after that.

richardhttps commented 2 years ago

Was about to open an issue for the same error but a clean reinstall fixed it, this time leaving the plugins path alone. I initially wanted my profiles to have their own packer subfolders like this:

...
    nvchad = { "~/.config/nvim/nvchad", {
            plugins = "packer/nvchad",
     ...

But leaving it to just "packer" solved it for me.

Good to hear - what exactly did you reinstall... would just starting with a totally blank ~/.config/nvim directory do it, or is there more you need to get rid of to do a fully clean install? Thought I did that but I can give it another shot. Otherwise I'll try what @tigorlazuardi suggested after that.

I just removed /packer directory and ~/.config/nvim and recloned. Sorry for the confusion.

harmolipi commented 1 year ago

I just removed /packer directory and ~/.config/nvim and recloned. Sorry for the confusion.

I just tried the same things a few times, and finally got it to start up without any errors, though I'm not sure what changed. Now though, while it runs and seems to install all of my plugins and open files without error, it's stuck looking more like the default neovim appearance with limited syntax highlighting, though I'm using a Neosolarized theme. It's like just the visuals aren't working, so I'm not sure what's causing that now.

alwyn commented 1 year ago

I am getting the same issue trying to get Astrovim to work.

Note to the developers. A lot of people who need something like cheovim are new to neovim and need it in order to experiment and learn from different configs. Your description of how to get it working relies too heavily on the person being familiar with neovim and/or the config in question.

Maybe a good solution would be to provide actual working samples for some popular configurations?

niscolas commented 1 year ago

I had this issue and in my case the problem was the packer wasn't installed (I had just removed its directory to test how cheovim would handle it). https://github.com/NTBBloodbath/cheovim/pull/20 should solve it, but you can use https://github.com/niscolas/cheovim for now if needed