Error info!

@Git-leng, you didn't include any information about the version of Vim you are using, or about the version of the NERDTree you are using (i.e., please include a commit hash). You must include all relevant information for anyone to make an assessment of your problem.
Closing due to inactivity.
I am having the same problem with Vim 8.0.707 (installed via Debian package manager). This only happens when I restore from a saved session with a NERDTree window in it.
Linux VM-DEV-DEB9 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u5 (2019-08-11) x86_64 GNU/Linux
:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 21 2019 04:10:35)
Included patches: 1-197, 322, 377-378, 550, 649, 651, 703, 706-707
Extra patches: 8.1.1401, 8.1.1382, 8.1.1368, 8.1.1367, 8.1.1366, 8.1.1365, 8.1.1046, 8.1.0613, 8.1.0547, 8.1.0546, 8.1.0544, 8.1.0540, 8.1.0539, 8.1.0538, 8.1.0506, 8.1.0208, 8.1.0206, 8.1.0205, 8.1.0189, 8.1.0177, 8.1.0067, 8.1.0066
Modified by [email protected]
Compiled by [email protected]
Huge version with GTK3 GUI. Features included (+) or not (-):
+acl +clientserver +cursorbind +ex_extra +gettext +libcall +mouse +mouse_xterm +persistent_undo +ruby +tag_old_static +toolbar +wildmenu -xterm_save
+arabic +clipboard +cursorshape +extra_search -hangul_input +linebreak +mouseshape +multi_byte +postscript +scrollbind -tag_any_white +user_commands +windows
+autocmd +cmdline_compl +dialog_con_gui +farsi +iconv +lispindent +mouse_dec +multi_lang +printer +signs +tcl +vertsplit +writebackup
+balloon_eval +cmdline_hist +diff +file_in_path +insert_expand +listcmds +mouse_gpm -mzscheme +profile +smartindent +termguicolors +virtualedit +X11
+browse +cmdline_info +digraphs +find_in_path +job +localmap -mouse_jsbterm +netbeans_intg -python +startuptime +terminfo +visual -xfontset
++builtin_terms +comments +dnd +float +jumplist +lua +mouse_netterm +num64 +python3 +statusline +termresponse +visualextra +xim
+byte_offset +conceal -ebcdic +folding +keymap +menu +mouse_sgr +packages +quickfix -sun_workshop +textobjects +viminfo +xpm
+channel +cryptv +emacs_tags -footer +lambda +mksession -mouse_sysmouse +path_extra +reltime +syntax +timers +vreplace +xsmp_interact
+cindent +cscope +eval +fork() +langmap +modify_fname +mouse_urxvt +perl +rightleft +tag_binary +title +wildignore +xterm_clipboard
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/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 -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/g
tk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include
/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time -g -O2 -fdebug-prefix-map=/build/vim-xBMBkh/vim-8.0.0197=. -fstack-protector-strong -Wformat
-Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbu
f-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib -llua5.2 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux
-gnu/perl/5.24/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.3 -lpthread -lgmp
-ldl -lcrypt -lm
:NERDTree:mksession! ~/vim_session:source ~/vim_sessionError detected while processing BufLeave Auto commands for "NERD_tree_*":
NERDTree windows cannot be restored with vim sessions. If you look at the session file, you'll see that vim is splitting the window, and renaming a new buffer to "NERD_tree_1", but it's still empty. NERDTree doesn't save the tree to disk, so it cannot be restored. Only a call to :NERDTree will restore the buffer to what it needs to be, and the session file doesn't do that for you. Part of what the NERDTree command does is set up buffer variables (b:NERDTree in particular), and because they're not present, the autocmds that NERDTree sets up fail.
I just run into a similar issue (with `thaerkh/vim-workspace).
"NERD_tree_1" [Not edited] --No lines in buffer--
Error detected while processing BufLeave Autocommands for "NERD_tree_*":
E121: Undefined variable: b:NERDTree
I don't care whether the NERDTree buffer is restored, but I'd rather get rid of the error above that I get when NERDTree was opened while exiting vim.
Is there a workaround?
I get this error many times every day when I get to work and I load my session.
Can you please do something about the error ... ? (I get that you do not want to restore the NERDTree window)
It looks like tweaking the 'sessionoptions' setting will solve the issue. Put this line in your .vimrc, and see if it solves the issue:
set sessionoptions-=blank
Your session file will not restore and empty windows you had, but in most cases, that's probably an acceptable trade-off.
Thank you! Indeed it fixed the stream of error messages I was getting, but now sometimes it modifies my layout when I had other "special" (plugin) windows that appear empty on session load
Most helpful comment
It looks like tweaking the
'sessionoptions'setting will solve the issue. Put this line in your .vimrc, and see if it solves the issue:Your session file will not restore and empty windows you had, but in most cases, that's probably an acceptable trade-off.