Shatur / neovim-cmake

CMake integration for Neovim
GNU General Public License v3.0
87 stars 19 forks source link

CMake select_target fails with error #21

Closed arcashka closed 2 years ago

arcashka commented 2 years ago

Bug description CMake select_target fails with error:

E5108: Error executing lua ...site/pack/packer/start/plenary.nvim/lua/plenary/path.lua:699: ENOENT: no such file or directory:                                                                                                                                                          
stack traceback:                                                                                                                                                                                                                                                                        
        [C]: in function 'assert'                                                                                                                                                                                                                                                       
        ...site/pack/packer/start/plenary.nvim/lua/plenary/path.lua:699: in function 'read'                                                                                                                                                                                             
        ...ack/packer/opt/neovim-cmake/lua/cmake/project_config.lua:71: in function 'get_codemodel_targets'                                                                                                                                                                             
        ...vim/site/pack/packer/opt/neovim-cmake/lua/cmake/init.lua:201: in function 'command_func'                                                                                                                                                                                     
        ...site/pack/packer/opt/neovim-cmake/lua/cmake/commands.lua:25: in function 'run_command'                                                                                                                                                                                       
        [string ":lua"]:1: in main chunk 

Steps to reproduce

I use default neovim-cmake settings. Steps:

  1. CMake create_project (C++, name: test2, folder ~/projects)
  2. CMake configure (works fine)
  3. CMake select target

Expected behavior Target selection works

Environment

Additional context I tried to debug it myself and got to this: If I change function ProjectConfig:get_codemodel_targets to this

function ProjectConfig:get_codemodel_targets()
  local reply_dir = self:get_reply_dir().filename
  local codemodel_vim = vim.fn.globpath(reply_dir, 'codemodel*')
  local codemodel = Path:new(codemodel_vim)
  utils.notify('reply_dir = ' .. reply_dir)
  utils.notify('codemodel = ' .. codemodel.filename)
  local codemodel_json = vim.fn.json_decode(codemodel:read())
  return codemodel_json['configurations'][1]['targets']
end

I get this in :Notifications

2022-01-21T18:12:21 CMake  INFO reply_dir = /home/arcashka/projects/test2/build/linux-debug/.cmake/api/v1/reply  
2022-01-21T18:12:21 CMake  INFO codemodel = 

This folder exists. And there is a file codemodel-v2-750e6d2bc098a122e68e.json. So I don't understand why vim.fn.globpath returns empty value. I'm totally new to lua too, so I can't make a progress with debug.

Shatur commented 2 years ago

Can't reproduce using your steps on my machine. Tested on ArchLinux with Neovim 0.6.1 and CMake 3.22.1.

arcashka commented 2 years ago

I managed to make a minimal config with only neovim-cmake. And bug is gone. That's my bad, sorry. I'm gonna try to fix it in my config.

So I'm gonna close this issue.