UNIX / Linux keyboard.

Fixing Error Messages About Missing GTK Modules

Failed to load module "libcanberra-gtk-module.so": libcanberra-gtk-module.so: cannot open shared object file: No such file or directory

So many of us have seen the above error message when we start Audacious or Wireshark mysterious, non-fatal but annoying messages scolding us about this missing GTK shared library. Things work. Our music starts playing, or our network protocol analyzer comes up ready to capture packets, but these messages are annoying. What causes this and how can we fix it?

The Canberra packages make up "a small and lightweight implementation of the XDG Sound Theme Specification". See my *nix package management page for details on how to examine the set of installed packages. Use rpm on most Linux distributions, dpkg on Debian and Ubuntu, and pkg_info on OpenBSD.

XMMS audio player running on Linux or BSD Unix.

On Mageia Linux using the KDE desktop I see the following list:

$ rpm -qa | grep canberra
canberra-common
canberra-gtk
lib64canberra-gtk
lib64canberra0

On some Ubuntu Linux systems I see this:

$ dpkg -l | grep canberra
gnome-session-canberra
libcanberra-gtk-module
libcanberra-gtk0
libcanberra-pulse
libcanberra0

And finally, on an OpenBSD Unix system I see just this:

$ pkg_info | grep canberra
libcanberra

Many people using Ubuntu Linux want to use the Gnome desktop with lots of "eye candy" and other effects turned on, but I have the so-called "system sound" turned off. I don't want a fancy context-specific BEEP blasting out of the speakers because file completion did not find an unambiguous match.

Why do I have the canberra packages installed on my Mageia Linux and OpenBSD systems?

Software dependencies, and unneeded environment variables.

The reason those error messages appear is because some environment variables cause those applications to look for things that aren't installed, or at least they aren't installed in the expected locations.

Try the following command. Its first line of output is the cause of the problem:

% env | grep -i gtk
GTK_MODULES=canberra-gtk-module
GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/cromwell/.gtkrc-2.0:/home/cromwell/.gtkrc-2.0-kde4:/home/cromwell/.kde4/share/config/gtkrc-2.0
GTK_RC_FILES=/etc/gtk/gtkrc:/home/cromwell/.gtkrc::/home/cromwell/.kde4/share/config/gtkrc

Amazon
ASIN: 1590597931

Amazon
ASIN: 0764506501

What causes this problem? I don't explicitly set that environment variable in any of my personal files!

Mageia Linux does this within /etc/X11/xinit.d/libcanberra-gtk-modules.sh where a graphical environment with anything other than Gnome sets a number of environment variables as the X session is started. These are then inherited by all interactive command sessions. Here is where these are set up. If the session is not Gnome, then if the environment variable GTK_MODULES does not exist it is set equal to canberra-gtk-module, and if it does exist, it is set to whatever it current is plus canberra-gtk-module. The result is then exported to the environment.

#!/bin/sh
# to be sourced

case "$SESSION" in
	GNOME)
		# Done by gnome-settings-daemon
		;;
	*)
		if [ -z "$GTK_MODULES" ] ; then
			GTK_MODULES="canberra-gtk-module"
		else
			GTK_MODULES="$GTK_MODULES:canberra-gtk-module"
		fi
		export GTK_MODULES
		;;
esac

I was tempted to just remove the package. However, dependencies eventually prevent this:

The solution

Simply edit /etc/X11/xinit.d/libcanberra-gtk-module.sh and comment out those lines:

#!/bin/sh
# to be sourced

case "$SESSION" in
	GNOME)
		# Done by gnome-settings-daemon
		;;
	*)
##		if [ -z "$GTK_MODULES" ] ; then
##		        GTK_MODULES="canberra-gtk-module"
##		else
##	        	GTK_MODULES="$GTK_MODULES:canberra-gtk-module"
##		fi
##		export GTK_MODULES
		;;
esac

Back to the Unix page