Ubuntu – How to stop gvim from crashing when opening a file

16.04gvimvim

I am on Ubuntu Desktop 16.04 LTS and gvim (vim with graphical user interface) keeps crashing on me when I try to open any file using the GUI/menu. However, I was able to open a file from the terminal, e.g:

user@computer:~$ vim -g ./path/to/file

The following error messages are printed to the terminal if I launch gvim from the terminal using vim -g and then cause the crash by trying to open a file via the GUI/menu bar:

(gvim:20175): GLib-CRITICAL **: g_ptr_array_insert: assertion 'index_ <= (gint)rarray->len' failed

** (gvim:20175): CRITICAL **: unity_gtk_menu_shell_get_item: assertion '0 <= index && index < items->len' failed

** (gvim:20175): CRITICAL **: unity_gtk_menu_item_get_child_shell: assertion 'UNITY_GTK_IS_MENU_ITEM (item)' failed

** (gvim:20175): CRITICAL **: unity_gtk_menu_shell_get_item: assertion '0 <= index && index < items->len' failed

** (gvim:20175): CRITICAL **: unity_gtk_menu_item_get_label: assertion 'UNITY_GTK_IS_MENU_ITEM (item)' failed

** (gvim:20175): CRITICAL **: unity_gtk_menu_item_get_icon: assertion 'UNITY_GTK_IS_MENU_ITEM (item)' failed
Vim: Caught deadly signal SEGV
Vim: Finished.

These are the vim-related packages I have installed:

user@computer:~$ apt list --installed | grep vim

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

vim-common/xenial-updates,now 2:7.4.1689-3ubuntu1.1 amd64 [installed]
vim-gtk3/xenial-updates,now 2:7.4.1689-3ubuntu1.1 amd64 [installed]
vim-gui-common/xenial-updates,xenial-updates,now 2:7.4.1689-3ubuntu1.1 all [installed,automatic]
vim-runtime/xenial-updates,xenial-updates,now 2:7.4.1689-3ubuntu1.1 all [installed,automatic]
vim-tiny/xenial-updates,now 2:7.4.1689-3ubuntu1.1 amd64 [installed]

Best Answer

Ubuntu 17.04

Things broke when I upgraded, and I solved it with:

sudo apt-get remove vim-gtk3
sudo apt-get install vim-gtk

vim-gnome mentioned in Adam P's answer says it points to vim-gtk3, so nothing would change.

vim-gtk however says it uses gtk 2, and worked.

Related Question