Skip to content

vim.uv field is nil causing error in init.lua #1073

@CSRept1l1an

Description

@CSRept1l1an

Describe the bug

When trying to initialize and use the uv module in Neovim, I encountered an error indicating that the vim.uv field is nil. This issue arises when using the fs_stat function to check if a path exists.

To Reproduce

  1. Use Neovim version v0.9.5.
  2. Add the following code to init.lua:
    if not vim.uv.fs_stat(lazypath) then
      local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
      local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
      if vim.v.shell_error ~= 0 then
        error('Error cloning lazy.nvim:\n' .. out)
      end
    end
    vim.opt.rtp:prepend(lazypath)
  3. Start Neovim.

Expected Behavior:
The uv module should be initialized correctly, allowing the use of fs_stat to check if a path exists.

Actual Behavior:
Neovim throws the following error:

E5113: Error while calling lua chunk: /home/kali/.config/nvim/init.lua:210: attempt to index field 'uv' (a nil value)
stack traceback:
        /home/kali/.config/nvim/init.lua:210: in main chunk
Press ENTER or type command to continue

Desktop

  • OS: Kali Linux
  • Terminal: GNOME Terminal

Neovim Version

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1719379426

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Additional Information:
Changing vim.uv to vim.loop resolves the issue:

local uv = vim.loop

if not uv.fs_stat(lazypath) then
  local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
  local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
  if vim.v.shell_error ~= 0 then
    error('Error cloning lazy.nvim:\n' .. out)
  end
end

vim.opt.rtp:prepend(lazypath)

Please let me know if this is the intended usage or if there are any additional configurations required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions