0

Basically, I am creating a .config/nvim for Neovim on my M1 Macbook Pro (Monterey 12.6), and I using the iTerm2 terminal emulator. I am having to create the entire configuration as a root user because the OS otherwise gives me a permission denied message whenever I run commends like mkdir in the .config folder. So, I am first running sudo -s and then setting up my Neovim configuration. When I first set it up and run it, it works, but the catch is that it only works if I am a root user. (This also puzzles me a lot because whenever I see tutorials on YouTube everyone is able to mkdir and create files without running sudo -s on their M1 MacOS in iTerm2) When I exit out of sudo and run nvim normally, I get the following error (something about my 'packpath'):

Error detected while processing /Users/abhinavmara/.config/nvim/init.lua:
E5113: Error while calling lua chunk: ...s/abhinavmara/.config/nvim/lua/maestro/plugins-setup.lua:6: Vim(packadd):E919: Directory not f
ound in 'packpath': "pack/*/opt/packer.nvim"

And I am also getting the exact same error in another file called packer_compiled.lua which is just the file that gets automatically created when packer is initially created. I am also getting an error about a ShaDa file permission denied:

E886: System error while opening ShaDa file /Users/abhinavmara/.local/state/nvim/shada/main.shada for reading: permission denied

I looked in my the path that was shown in error E5113 (the one about packpath), and I have nothing in the ../opt directory, and I have all my plugins in the ../start directory and that is where the packer.nvim exists as well. I have tried moving the packer.nvim into the ../opt directory but I still get the same errors. I have also tried doing the following:

vim.o.packpath = vim.o.packpath .. "," .. "~/.local/share/nvim/site/pack/packer/opt/packer.nvim"

But that also gives me the exact same errors.

I am just wondering what exactly I need to do how I have to configure Neovim so that I can use it without being a root user (as that can be very dangerous).

5
  • I strongly suggest taking a close look at the permissions on all the directories in ~/.local and ~/.config or even ~. (For example: ls -l.) You may need to sudo chown those back to yourself. You should never need sudo to edit your personal config. Have you run sudo vim or similar before? It's possible that caused a problem; use sudoedit instead.
    – D. Ben Knoble
    Commented Nov 8, 2022 at 19:04
  • Ok, so I have changed the .config,.local, and all the nvim-related directories within to myself instead of root so that I can change them without called sudo. That managed to solve my problem of not being able to open or run nvim to make files in the .config and the issues with the Shada file, but I still have issues with the 'packpath' (E5113). Anything else that I can do to solve that issue? Let me know if I need to post and give any other information... Commented Nov 8, 2022 at 19:51
  • The packpath issue might be related or might not be; check the (permissions on the) directories in :put =split(&packpath, ',')
    – D. Ben Knoble
    Commented Nov 8, 2022 at 23:26
  • It has worked. I looked into the permissions for the .local directory where the packer.nvim exists and just looked into whatever error it threw again to and set myself to the user by called sudo chown [username] [directory/file]. Thank you for your help. Commented Nov 9, 2022 at 1:35
  • please add an answer!
    – D. Ben Knoble
    Commented Nov 10, 2022 at 21:30

1 Answer 1

0

Based on the comments with D. Ben Knoble: Check all your directory permissions again:

1
  • 2
    Maybe you could be more explicitly about what you propose and separate better the answer from the references Commented Mar 9 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.