Civitasv/cmake-tools.nvim

Build Directory Creation will Fail if it Requires a Recursive Create on Windows

Closed this issue · 4 comments

Bug description
During the generate step if your output directory requires a recursive create on Windows it will fail. In my example my output directory is ${CMAKE_SOURCE_DIR}/out/Debug/.

If the directory "out" exists the command succeeds, but if it does not the command will fail.

Error executing Lua callback: ...a/Local/nvim-data/lazy/plenary.nvim/lua/plenary/path.lua:505: We couldn't mkdir: C:\repos\CppTemplate\out/Debug
stack traceback:
        [C]: in function 'error'
        ...a/Local/nvim-data/lazy/plenary.nvim/lua/plenary/path.lua:505: in function 'mkdir'
        ...im-data/lazy/cmake-tools.nvim/lua/cmake-tools/config.lua:120: in function 'generate_build_directory'
        ...nvim-data/lazy/cmake-tools.nvim/lua/cmake-tools/init.lua:162: in function <...nvim-data/lazy/cmake-tools.nvim/lua/cmake-tools/init.lua:61>

Steps to reproduce
clone https://github.com/natecheadle/CppTemplate
nvim .
:CMakeGenerate

Expected behavior
I would expect no failure on the generate step.

Environment

  • OS: Windows
  • Plugins commit hash: 1c309e4

i debugged it and it seems like plenary doesnt split on \ sign on linux, as i really dont want to create a windows vm im just curious if this could change the error or fix it, if You change out directory in config to cmake_build_directory = "out\\${variant:buildType}", as it might be an error with it just not understanding the other slash

if this works i'll link a pull request to change default for windows and maybe add a disclaimer

Changing the build directory as you describe works.

This probably isn't a surprise based on what I assume your fix will be, but using CMakePresets to set the binary directory works without issues.

i tried fixing it the most basic way and put handling of windows slashes in all paths in my personal TODO list i'll do it if there will be more simmilar path errors on windows