Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: cache_loader unable to load module correctly #803

Closed
3 tasks done
mehalter opened this issue May 17, 2023 · 3 comments · Fixed by #804
Closed
3 tasks done

bug: cache_loader unable to load module correctly #803

mehalter opened this issue May 17, 2023 · 3 comments · Fixed by #804
Labels
bug Something isn't working

Comments

@mehalter
Copy link

mehalter commented May 17, 2023

Did you check docs and existing issues?

  • I have read all the lazy.nvim docs
  • I have searched the existing issues of lazy.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.0 release

Operating system/version

Arch Linux (also verified on Windows and Mac OS X)

Describe the bug

It appears when I set up Mason.nvim and use the build key along with the built in setup (either config = function() ... end/opts = {...}/config = true), it causes some errors with the cache_loader specifically if I am also importing other plugins with import = ....

I'm not sure what is causing this error in the code base, but it looks like if I remove the setup stuff by removing config and/or opts then the error goes away, if I remove the entry in the plugins table that does import = ... then the error also goes away.

Note: This also seems to only happen when I start from a completely clean environment, cleared out state/cache/data folders and everything. After the first start up the error goes away.

Error:

Error detected while processing /home/micah/.config/nvim_lazy-bug/init.lua:                                                       
Failed to run `config` for mason.nvim                                                                                             
/home/micah/.config/nvim_lazy-bug/init.lua:23: module 'mason' not found:                                                          
^Ino field package.preload['mason']                                                                                               
cache_loader: module mason not found                                                                                              
cache_loader_lib: module mason not found                                                                                          
^Ino file './mason.lua'                                                                                                           
^Ino file '/home/runner/work/neovim/neovim/.deps/usr/share/luajit-2.1.0-beta3/mason.lua'                                          
^Ino file '/usr/local/share/lua/5.1/mason.lua'                                                                                    
^Ino file '/usr/local/share/lua/5.1/mason/init.lua'                                                                               
^Ino file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/mason.lua'                                                     
^Ino file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/mason/init.lua'                                                
^Ino file './mason.so'                                                                                                            
^Ino file '/usr/local/lib/lua/5.1/mason.so'                                                                                       
^Ino file '/home/runner/work/neovim/neovim/.deps/usr/lib/lua/5.1/mason.so'                                                        
^Ino file '/usr/local/lib/lua/5.1/loadall.so'                                                                                     
# stacktrace:                                                                                                                     
  - ~/.config/nvim_lazy-bug/init.lua:23 _in_ **config**                                                                           
  - ~/.config/nvim_lazy-bug/init.lua:29 

Steps To Reproduce

  1. Use the minimal reproducing Lua file below
  2. Make sure you are in a clean environment, clear out the state/data/cache folders (using the reproduction file below, just run rm -rf .repo)
  3. run nvim and wait for lazy to install packages
  4. run :messages to see the full message

Expected Behavior

There shouldn't be an error inside of the mason config function should not have any issue loading the package and accessing it with require("mason").

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "cache" } do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system { "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath }
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "williamboman/mason.nvim",
    build = ":MasonUpdate", -- must have build command and config to setup package
    config = function(_, opts) require("mason").setup(opts) end,
  },
  "AstroNvim/astrocommunity", -- also must import some plugin specifications from somewhere
  { import = "astrocommunity.colorscheme.catppuccin" },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme "tokyonight"
@folke
Copy link
Owner

folke commented May 17, 2023

There was indeed a bug that didn't properly reset part of the cache when installing plugins. Fixed now!

@mehalter
Copy link
Author

Thanks so much for the quick fix! Us over at AstroNvim really appreciate all your work with Lazy ❤️ Sorry again for a bit of the noise that was created earlier before the bug was properly identified and understood.

@folke
Copy link
Owner

folke commented May 17, 2023

No worries. Glad you reported it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants