cdelledonne / vim-cmake

Vim/Neovim plugin for working with CMake projects
MIT License
259 stars 21 forks source link

E121: Undefined variable: s:cmake_version #27

Closed Andoku closed 2 years ago

Andoku commented 3 years ago

Describe the bug Trying to run CMakeGenerate, but getting error: Undefined variable: s:cmake_version cmake is installed, version 3.19.2

To Reproduce Steps to reproduce the behavior:

  1. Run :CMakeGenerate

Screenshots Screenshot 2021-01-17 at 02 50 46

Other info

cdelledonne commented 3 years ago

Hi, thanks a lot for reporting this. I'll take a look as soon as possible, I'm currently a little busy with work.

cdelledonne commented 3 years ago

I tried using the same version of CMake as you, but I could not reproduce your issue. I have a few questions:

Andoku commented 3 years ago

I tried using the same version of CMake as you, but I could not reproduce your issue. I have a few questions:

  • Did you try to pull the latest version of this plugin and try to run :CMakeGenerate again?

Yes, tried it right now again, same error

  • Is the cmake executable in your PATH? If not, did you set g:cmake_command accordingly?

Yes, I can run cmake from terminal and tried setting let g:cmake_command='cmake', but nothing helps Screenshot_2021-01-22_17-11-26

cdelledonne commented 3 years ago

Thank you for trying. One more thing then: restart Vim, then try to call :CMakeGenerate again, and after you get the error message, call :messages. Then post here the output, if there is any.

Andoku commented 3 years ago

Thank you for trying. One more thing then: restart Vim, then try to call :CMakeGenerate again, and after you get the error message, call :messages. Then post here the output, if there is any.

Screenshot 2021-01-22 at 21 04 24

cdelledonne commented 3 years ago

Apologies for the delay on this, at the moment I am quite busy with some other stuff and cannot work on this plugin too much.

I still can't reproduce this. Would you be willing to debug this for me? You could modify the source code and add log statements using cmake#util#Log(level, message). You can use 'I' as level.

If you don't feel like it, I can scatter some more log statements around the code and push a new branch, and then you could checkout that branch and help me debug it with you.

Thank you for your patience.

Andoku commented 3 years ago

@cdelledonne I debbuged it a little and found out that somehow line 19 in generate.vim call cmake#command#Run(s:command, 1, 1, function('s:GetCMakeVersionCb'))

Doesn't get called at all, how can it be? I added print before, after and inside this call (inside Run). Before and After were printed but inside wasn't.

cdelledonne commented 3 years ago

What's the output of :version?

Andoku commented 3 years ago

@cdelledonne

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jan 20 2021 22:47:34)
Included patches: 1-2380
Compiled by Arch Linux
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +cryptv            +fork()            +modify_fname      +persistent_undo   +syntax            +visualextra
+arabic            +cscope            +gettext           +mouse             +popupwin          +tag_binary        +viminfo
+autocmd           +cursorbind        -hangul_input      +mouseshape        +postscript        -tag_old_static    +vreplace
+autochdir         +cursorshape       +iconv             +mouse_dec         +printer           -tag_any_white     +wildignore
-autoservername    +dialog_con_gui    +insert_expand     +mouse_gpm         +profile           +tcl/dyn           +wildmenu
+balloon_eval      +diff              +ipv6              -mouse_jsbterm     +python/dyn        +termguicolors     +windows
+balloon_eval_term +digraphs          +job               +mouse_netterm     +python3/dyn       +terminal          +writebackup
+browse            +dnd               +jumplist          +mouse_sgr         +quickfix          +terminfo          +X11
++builtin_terms    -ebcdic            +keymap            -mouse_sysmouse    +reltime           +termresponse      -xfontset
+byte_offset       +emacs_tags        +lambda            +mouse_urxvt       +rightleft         +textobjects       +xim
+channel           +eval              +langmap           +mouse_xterm       +ruby/dyn          +textprop          -xpm
+cindent           +ex_extra          +libcall           +multi_byte        +scrollbind        +timers            +xsmp_interact
+clientserver      +extra_search      +linebreak         +multi_lang        +signs             +title             +xterm_clipboard
+clipboard         -farsi             +lispindent        -mzscheme          +smartindent       +toolbar           -xterm_save
+cmdline_compl     +file_in_path      +listcmds          +netbeans_intg     +sound             +user_commands     
+cmdline_hist      +find_in_path      +localmap          +num64             +spell             +vartabs           
+cmdline_info      +float             +lua/dyn           +packages          +startuptime       +vertsplit         
+comments          +folding           +menu              +path_extra        +statusline        +virtualedit       
+conceal           -footer            +mksession         +perl/dyn          -sun_workshop      +visual            
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cloudproviders -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1

Linking: gcc -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.32/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lcanberra -lacl -lattr -lgpm -ldl -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.32/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib -L/usr/lib/perl5/5.32/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm
Andoku commented 3 years ago

@cdelledonne I investigated a little bit further - if i change line 162 manually for my version: if 319 < 313 Everything works fine. So the main problem is call cmake#command#Run(s:command, 1, 1, function('s:GetCMakeVersionCb')) at line 19 doesn't work somehow

cdelledonne commented 3 years ago

Hi, thanks a lot again for investigating this.

I have found some time to look into my code, and I might have identified the issue. Basically it could happen that the external job cmake --version invoked by Vim-CMake returns so quickly that we didn't even have the time to set the reference to the callback to be invoked—in this case, s:GetCMakeVersionCb.

Technicalities aside, I've pushed a potential fix on the branch 27-undefined-variable-s-cmake-version. Could you please try to checkout that branch and let me know if you still get the "Undefined variable" error? To checkout that branch with e.g. vim-plug you can do

Plug 'cdelledonne/vim-cmake', { 'branch': '27-undefined-variable-s-cmake-version' }

Thank you in advance.

Andoku commented 3 years ago

@cdelledonne now when I run :CMakeGenerate everything gets stuck (freezes) and only closing editor helps

cdelledonne commented 3 years ago

Ah interesting, yes makes sense :)

I removed the culprit, and added some log statements. Could you please pull the latest updates to the branch 27-undefined-variable-s-cmake-version, then restart Vim, then try to call :CMakeGenerate again, and then post the output of :messages?

Once again, thank you for debugging this with me.

cdelledonne commented 3 years ago

I have actually pushed a more recent version of that branch with a potential fix. When you have time to test it, please let me know if the whole problem is solved.

Andoku commented 3 years ago

@cdelledonne it seems that now everything works

cdelledonne commented 3 years ago

That's great! I'll merge the fix then

tafryn commented 3 years ago

@cdelledonne I'm having this same issue with the most recent version.

cdelledonne commented 3 years ago

@tafryn thank you for reporting this, I have reopened this issue to investigate the problem further.

As I cannot reproduce the issue, could you please try to reproduce it with a minimal vimrc, and post the content of this vimrc here? Also, are you running the nvim.appimage binary or something else?

Thank you for patiently waiting for my answer :)

NitroCao commented 3 years ago

@tafryn Please check the output of cmake --version. I guess your output is cmake3 version 3.17.5. If so, please replace cmake with cmake3 in the following line https://github.com/cdelledonne/vim-cmake/blob/d4ea81eb0604ec8b64be6a3159ef14b7263ff4ed/autoload/cmake/generate.vim#L8

cdelledonne commented 2 years ago

@NitroCao which combination of OS and CMake package outputs cmake3 version ... instead of cmake version ...? My CentOS virtual machine with CMake 3.17.5 does not do that.

NitroCao commented 2 years ago

CentOS 7.2.1511, cmake3 package in epel repo.

$ yum info cmake3
Installed Packages
Name        : cmake3
Arch        : x86_64
Version     : 3.17.5
Release     : 1.el7
Size        : 26 M
Repo        : installed
From repo   : epel
Summary     : Cross-platform make system
URL         : http://www.cmake.org
License     : BSD and MIT and zlib
Description : CMake is used to control the software compilation process using simple
            : platform and compiler independent configuration files. CMake generates
            : native makefiles and workspaces that can be used in the compiler
            : environment of your choice. CMake is quite sophisticated: it is possible
            : to support complex environments requiring system configuration, preprocessor
            : generation, code generation, and template instantiation.
CleanShot 2021-12-13 at 12 17 04@2x

@NitroCao which combination of OS and CMake package outputs cmake3 version ... instead of cmake version ...? My CentOS virtual machine with CMake 3.17.5 does not do that.

cdelledonne commented 2 years ago

Ah yes, tried to install cmake3 from epel and indeed that's the output. I pushed a fix for this, it's on the latest master. I'm closing this issue then, let me know if there are still problems.