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

UpdateRemotePlugins not finding any specs #564

Closed
tanj opened this issue Apr 10, 2024 · 1 comment · Fixed by #565
Closed

UpdateRemotePlugins not finding any specs #564

tanj opened this issue Apr 10, 2024 · 1 comment · Fixed by #565

Comments

@tanj
Copy link
Contributor

tanj commented Apr 10, 2024

I'm trying to figure out why UpdateRemotePlugins is not finding any plugins. I hacked in some printf debugging into runtime/autoload/remote/host.vim and it seems like when function! s:RegistrationCommands calls rpcrequest(channel, 'specs', path) it doesn't seem to come back with any specs.

paths: ['C:/Users/<user>/AppData/Local/nvim/rplugin/python3/__pycache__',
'C:/Users/<user>/AppData/Local/nvim/rplugin/python3/example.py',
'C:/Users/<user>/AppData/Local/nvim/rplugin/python3/limit.py']
no spec found: 0 
no spec found: 0 
no spec found: 0 
remote/host: python3 host registered plugins [] 
remote/host: generated rplugin manifest: C:\Users\<user>\AppData\Local\nvim-data/rplugin.vim 
  • example.py is the example from the pynvim docs
  • limit.py is the example from the neovim docs on remote plugins

Modified function for my printf debug

function! s:RegistrationCommands(host) abort
  " Register a temporary host clone for discovering specs
  let host_id = a:host.'-registration-clone'
  call remote#host#RegisterClone(host_id, a:host)
  let pattern = s:plugin_patterns[a:host]
  let paths = nvim_get_runtime_file('rplugin/'.a:host.'/'.pattern, 1)
  let paths = map(paths, 'tr(resolve(v:val),"\\","/")') " Normalize slashes #4795
  let paths = uniq(sort(paths))
  if empty(paths)
    return []
  endif

  for path in paths
    call remote#host#RegisterPlugin(host_id, path, [])
  endfor
  let channel = remote#host#Require(host_id)
  let lines = []
  let registered = []
  echomsg printf("paths: %s", paths)
  for path in paths
    unlet! specs
    let specs = rpcrequest(channel, 'specs', path)
    if type(specs) != type([])
      " host didn't return a spec list, indicates a failure while loading a
      " plugin
      echomsg printf("no spec found: %s", specs)
      continue
    endif
    echomsg printf("found spec: %s", specs)
    call add(lines, "call remote#host#RegisterPlugin('".a:host
          \ ."', '".path."', [")
    for spec in specs
      call add(lines, "      \\ ".string(spec).",")
    endfor
    call add(lines, "     \\ ])")
    call add(registered, path)
  endfor
  echomsg printf("remote/host: %s host registered plugins %s",
        \ a:host, string(map(registered, "fnamemodify(v:val, ':t')")))

  " Delete the temporary host clone
  call jobstop(s:hosts[host_id].channel)
  call remove(s:hosts, host_id)
  call remove(s:plugins_for_host, host_id)
  return lines
endfunction

Neovim version

% nvim --version
NVIM v0.10.0-dev-2830+g541c2d381
Build type: RelWithDebInfo
LuaJIT 2.1.1710088188

OS

Windows 11 Pro

@tanj
Copy link
Contributor Author

tanj commented Apr 13, 2024

I did some digging with adding some log spam and I think the issue is that we have a mix of windows path separators and posix path separators.

2024-04-13 08:52:57,652 [INFO @ host.py:start:82] 27388 - Start host ['C:/Users/<user>/AppData/Local/nvim/rplugin/python3/example.py', 'C:/Users/jtebokkel/AppData/Local/nvim/rplugin/python3/limit.py']
2024-04-13 08:52:57,652 [DEBUG @ session.py:run:170] 27388 - Checking if we have setup callback...
2024-04-13 08:52:57,652 [DEBUG @ session.py:run:172] 27388 - Starting greenlet for on_setup
2024-04-13 08:52:57,653 [INFO @ host.py:_discover_functions:232] 27388 - Discovering functions... C:\Users\<user>\AppData\Local\nvim\rplugin\python3\example.py
2024-04-13 08:52:57,653 [INFO @ host.py:_discover_functions:237] 27388 - discover function: <function TestPlugin.on_bufenter at 0x000001F5F6406980>
2024-04-13 08:52:57,654 [INFO @ host.py:_discover_functions:268] 27388 - <function TestPlugin.on_bufenter at 0x000001F5F6406980> has spec: {'type': 'autocmd', 'name': 'BufEnter', 'sync': True, 'opts': {'pattern': '*.py', 'eval': 'expand("<afile>")'}}
2024-04-13 08:52:57,654 [INFO @ host.py:_discover_functions:237] 27388 - discover function: <function TestPlugin.testcommand at 0x000001F5F64068E0>
2024-04-13 08:52:57,654 [INFO @ host.py:_discover_functions:268] 27388 - <function TestPlugin.testcommand at 0x000001F5F64068E0> has spec: {'type': 'command', 'name': 'TestCommand', 'sync': False, 'opts': {'range': '', 'nargs': '*'}}
2024-04-13 08:52:57,654 [INFO @ host.py:_discover_functions:237] 27388 - discover function: <function TestPlugin.testfunction at 0x000001F5F6406840>
2024-04-13 08:52:57,654 [INFO @ host.py:_discover_functions:268] 27388 - <function TestPlugin.testfunction at 0x000001F5F6406840> has spec: {'type': 'function', 'name': 'TestFunction', 'sync': True, 'opts': {}}
2024-04-13 08:52:57,654 [INFO @ host.py:_discover_functions:274] 27388 - specs collected: [{'type': 'autocmd', 'name': 'BufEnter', 'sync': True, 'opts': {'pattern': '*.py', 'eval': 'expand("<afile>")'}}, {'type': 'command', 'name': 'TestCommand', 'sync': False, 'opts': {'range': '', 'nargs': '*'}}, {'type': 'function', 'name': 'TestFunction', 'sync': True, 'opts': {}}]
2024-04-13 08:52:57,654 [INFO @ host.py:_discover_functions:277] 27388 - self._specs: {'C:\\Users\\<user>\\AppData\\Local\\nvim\\rplugin\\python3\\example.py': [{'type': 'autocmd', 'name': 'BufEnter', 'sync': True, 'opts': {'pattern': '*.py', 'eval': 'expand("<afile>")'}}, {'type': 'command', 'name': 'TestCommand', 'sync': False, 'opts': {'range': '', 'nargs': '*'}}, {'type': 'function', 'name': 'TestFunction', 'sync': True, 'opts': {}}]}

added one more debug log and confirm issue

2024-04-13 09:06:09,989 [INFO @ host.py:_on_specs_request:287] 34876 - on_specs_request path: 'C:/Users/<user>/AppData/Local/nvim/rplugin/python3/example.py'

we are adding the specs with path = os.path.normpath(path) and looking them up with no change in path.

This was introduced in f244597

justinmk pushed a commit that referenced this issue Apr 14, 2024
Specs were being found with a normalized path, but being requested
without normalization. We now normalize the path we responding to spec
requests.

fixes #564
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant