Shougo / dein.vim

:zap: Dark powered Vim/Neovim plugin manager
MIT License
3.43k stars 198 forks source link

Can't load toml cache. #416

Closed uga-rosa closed 3 years ago

uga-rosa commented 3 years ago

Problems summary

Can't load toml cache. In my case, even if I cut it down to this level, it still echoes failed on starting.

Expected

I have no idea.

Environment Information (Required!)

Provide a minimal .vimrc with less than 50 lines (Required!)

"init.vim
let s:dein_dir = expand('~/.cache/dein')
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
let s:dein_toml = '~/.config/nvim/dein.toml'

if &runtimepath !~# '/dein.vim'
  if !isdirectory(s:dein_repo_dir)
    execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir
  endif
  execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p')
endif

if !dein#load_state(s:dein_dir)
  echo 'success'
  finish
endif

call dein#begin(s:dein_dir)
call dein#load_toml(s:dein_toml,      {'lazy': 0})
call dein#end()
call dein#save_state()
echo 'failed'

if dein#check_install()
  call dein#install()
endif
#dein.toml
[[plugins]]
repo = 'Shougo/dein.vim'

The reproduce ways from Vim starting (Required!)

  1. Just start up.

Screen shot (if possible)

image

Shougo commented 3 years ago

I have tested your minimal vimrc and it works for me.

Shougo commented 3 years ago

It seems dein#load_cache_raw() error. Please debug it like this.

diff --git a/autoload/dein.vim b/autoload/dein.vim
index 3ee4253..9566c1a 100644
--- a/autoload/dein.vim
+++ b/autoload/dein.vim
@@ -66,11 +66,17 @@ function! dein#load_cache_raw(vimrcs) abort
   let cache = get(g:, 'dein#cache_directory', g:dein#_base_path)
         \ .'/cache_' . g:dein#_progname
   let time = getftime(cache)
+  echomsg time
+  echomsg filter(map(copy(g:dein#_vimrcs),
+        \ { _, val -> getftime(expand(val)) })
   if !empty(filter(map(copy(g:dein#_vimrcs),
         \ { _, val -> getftime(expand(val)) }), { _, val -> time < val }))
     return [{}, {}]
   endif
   let list = readfile(cache)
+  echomsg len(list)
+  echomsg string(g:dein#_vimrcs)
+  echomsg list[0]
   if len(list) != 3 || string(g:dein#_vimrcs) !=# list[0]
     return [{}, {}]
   endif
uga-rosa commented 3 years ago
diff --git a/autoload/dein.vim b/autoload/dein.vim
index 3ee4253..64e554d 100644
--- a/autoload/dein.vim
+++ b/autoload/dein.vim
@@ -66,11 +66,17 @@ function! dein#load_cache_raw(vimrcs) abort
   let cache = get(g:, 'dein#cache_directory', g:dein#_base_path)
         \ .'/cache_' . g:dein#_progname
   let time = getftime(cache)
+  echomsg time
+  echomsg filter(map(copy(g:dein#_vimrcs),
+        \ { _, val -> getftime(expand(val)) }), { _, val -> time < val })
   if !empty(filter(map(copy(g:dein#_vimrcs),
         \ { _, val -> getftime(expand(val)) }), { _, val -> time < val }))
     return [{}, {}]
   endif
   let list = readfile(cache)
+  echomsg len(list)
+  echomsg string(g:dein#_vimrcs)
+  echomsg list[0]
   if len(list) != 3 || string(g:dein#_vimrcs) !=# list[0]
     return [{}, {}]
   endif

call dein#load_cache_raw(g:dein#_vimrcs)

1628692991
[]
3
['/home/<username>/dotfiles/nvim/init.vim', '/home/<username>/.config/nvim/dein.toml', '/home/<username>/.config/nvim/dein_lazy.toml']
['/home/<username>/dotfiles/nvim/init.vim', '/home/<username>/.config/nvim/dein.toml', '/home/<username>/.config/nvim/dein_lazy.toml']
uga-rosa commented 3 years ago
@@ -89,8 +95,10 @@ function! dein#load_state(path, ...) abort
         \ . '/state_' . g:dein#_progname . '.vim'
   if !filereadable(state) | return 1 | endif
   try
+    echomsg fnameescape(state)
     execute 'source' fnameescape(state)
   catch
+    echomsg string(v:exception)
     if v:exception !=# 'Cache loading error'
       call dein#util#_error('Loading state error: ' . v:exception)
     endif

neovim starting message

/home/<username>/.cache/dein/state_nvim.vim
'Cache loading error'
Shougo commented 3 years ago

call dein#load_cache_raw(g:dein#_vimrcs)

Why you have called dein#load_cache_raw() manually? I think it is not called in startup.

So please read below code.

  let lines = [
        \ 'if g:dein#_cache_version !=# ' . g:dein#_cache_version . ' || ' .
        \ 'g:dein#_init_runtimepath !=# ' . string(g:dein#_init_runtimepath) .
        \      ' | throw ''Cache loading error'' | endif',
        \ 'let [plugins, ftplugin] = dein#load_cache_raw('.
        \      string(g:dein#_vimrcs) .')',
        \ "if empty(plugins) | throw 'Cache loading error' | endif",
        \ 'let g:dein#_plugins = plugins',
        \ 'let g:dein#_ftplugin = ftplugin',
        \ 'let g:dein#_base_path = ' . string(g:dein#_base_path),
        \ 'let g:dein#_runtime_path = ' . string(g:dein#_runtime_path),
        \ 'let g:dein#_cache_path = ' . string(g:dein#_cache_path),
        \ 'let &runtimepath = ' . string(&runtimepath),
        \ ]

Please compare both g:dein#_cache_version and g:dein#_init_runtimepath with your state file values. If it is not same, it will be returned before dein#load_cache_raw() call.

I think g:dein#_init_runtimepath is not same. Why it is not same? I don't know... It should same if you use the minimal vimrc.

call dein#load_cache_raw(g:dein#_vimrcs)

echo dein#load_cache_raw(g:dein#_vimrcs) is better. Please check the return value is not empty lists.

Shougo commented 3 years ago

Have you change &runtimepath after dein#load_state()?

uga-rosa commented 3 years ago

g:dein#_cache_version and g:dein#_init_runtimepath are same with state file values. echo dein#load_cache_raw(g:dein#_vimrcs) returned the value is NOT empty list. The only change I made to the runtimepath that I set up myself is the addition of dein before dein#load_state().

P.S. dein#load_cache_raw() is not called in startup.

Shougo commented 3 years ago

OK. So please debug your state file. It checks g:dein#_cache_version and g:dein#_init_runtimepath.

P.S. dein#load_cache_raw() is not called in startup.

The reason is found. It fails the version check or the runtimepath check. The script is under your cache directory. You can debug it.

Shougo commented 3 years ago

g:dein#_cache_version and g:dein#_init_runtimepath are same with state file values.

It is really same when the script is executed? If so why the check is failed? dein#load_cache_raw() is not called.

Shougo commented 3 years ago

I can remove the check easily. But it is not the true fix for it.

uga-rosa commented 3 years ago

I don't know the cause, it's not reproducible, and there are other options for the plugin manager. I can't motivate myself any more. I'm sorry.

Shougo commented 3 years ago

Oh