Everytime I close a gvim window with the little x on the window or Alt + F4. I get the following error and have to hit return to get my command prompt back. Has anyone seen this?

(gvim:26639): GLib-GObject-WARNING **: cannot retrieve class for invalid (unclassed) type `<invalid>'

Normally, GLib-GObject-WARNING while running gtk applications in the command line, are normally ignored by developers and demonstrate a poorly written applications. If you report a bug against the package, it would be the best, but don't act surprised if developers ignore or say that "is ok" in your bug report.

TL;dr: They are normally safe to be ignored.


vim-gnome has this problem, but vim-gtk does not, so this is a quick fix for the problem:

sudo apt remove vim-gnome
sudo apt install vim-gtk
  • 3
    It's worth noting that vim-gtk3 (which includes the GNOME3 integration) also doesn't emit this warning – Zrax May 5 '17 at 20:03
  • 2
    What is the difference between vim-gnome and vim-gtk3 or vim-gtk3-py2? Why is vim-gnome the default in Ubuntu 16.04? – Hans Deragon Oct 7 '17 at 12:02
  • sudo apt-get install vim-gtk3 – Arun Saha Feb 17 '18 at 15:59
  • 1
    @HansDeragon See askubuntu.com/questions/33260/… – Arun Saha Feb 17 '18 at 16:00
  • 1
    sudo apt-get remove vim-gnome && sudo apt-get install vim-gtk3 – Arun Saha Mar 24 '18 at 21:42

I found myself caught between the spurious Warning (vim-gnome) or an empty file bug with vim-gtk3. Open an existing file, then try switching to a new file that doesn't exist using

:e newEmptyFile => SEGV

So I'm back to using vim-gnome with this hack in my ~/.bash_aliases to shutup vim-gnome:

alias gvim='gvim 2>/dev/null'

I'm sure it will get fixed soon and I won't have to keep throwing away all errors because of a persistent spurious warning.

  • Perfect 1 minute solution for a rookie like me :) I tried to replace vim-gnome with viw-gtk or vim-gtk3, but still got the error. The alias is an easy solution. Moreover, if I am not wrong, one still can get error by "canceling" the alias with a backslash \gvim foo.txt to call the original \gvim application – el-teedee Sep 9 '18 at 1:14
  • You could always pipe the stderr to a grep -v 'cannot retrieve class for invalid (unclassed) type' (or more detailed if you like) and get on with your life, no? :) – tgm1024--Monica was mistreated Feb 7 at 18:00


sudo update-alternatives --config gvim

then select /usr/bin/vim.gtk-py2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.