Hello,
This is the code that generate the full message [
1]:
Code: Select all
if (!gtk_init_check(&argc, &argv)) {
std::cout <<
_("Failed to initialize GTK.\n") <<
"\n" <<
_("Probably you're running Synaptic on Wayland with root permission.\n") <<
_("Please restart your session without Wayland, or run Synaptic without root permission\n");
exit(1);
};
According to gtk source code [2]:
Code: Select all
* Before using GTK+, you need to initialize it; initialization connects to the
* window system display, and parses some standard command line arguments. The
* gtk_init() macro initializes GTK+. gtk_init() exits the application if errors
* occur; to avoid this, use gtk_init_check(). gtk_init_check() allows you to
* recover from a failed GTK+ initialization - you might start up your
* application in text mode instead.
This is the source code for for gtk_init_check [3]:
Code: Select all
/**
* gtk_init_check:
* @argc: (inout): Address of the `argc` parameter of
* your main() function (or 0 if @argv is %NULL). This will be changed if
* any arguments were handled.
* @argv: (array length=argc) (inout) (allow-none): Address of the
* `argv` parameter of main(), or %NULL. Any options
* understood by GTK+ are stripped before return.
*
* This function does the same work as gtk_init() with only a single
* change: It does not terminate the program if the windowing system
* can’t be initialized. Instead it returns %FALSE on failure.
*
* This way the application can fall back to some other means of
* communication with the user - for example a curses or command line
* interface.
*
* Returns: %TRUE if the windowing system has been successfully
* initialized, %FALSE otherwise
*/
gboolean
gtk_init_check (int *argc,
char ***argv)
{
gboolean ret;
if (!gtk_parse_args (argc, argv))
return FALSE;
ret = gdk_display_open_default_libgtk_only () != NULL;
if (debug_flags & GTK_DEBUG_INTERACTIVE)
gtk_window_set_interactive_debugging (TRUE);
return ret;
}
This is the source code for gdk_display_open_default_libgtk_only function (used by gtk_init_check): [4]
Code: Select all
/**
* gdk_display_open_default_libgtk_only:
*
* Opens the default display specified by command line arguments or
* environment variables, sets it as the default display, and returns
* it. gdk_parse_args() must have been called first. If the default
* display has previously been set, simply returns that. An internal
* function that should not be used by applications.
*
* Returns: (nullable) (transfer none): the default display, if it
* could be opened, otherwise %NULL.
**/
GdkDisplay *
gdk_display_open_default_libgtk_only (void)
{
GdkDisplay *display;
g_return_val_if_fail (gdk_initialized, NULL);
display = gdk_display_get_default ();
if (display)
return display;
display = gdk_display_open (gdk_get_display_arg_name ());
return display;
}
So, it seems that synaptic tries opening the X11 display, but it fails.
As suggested in the error message:
run Synaptic without root permission
you must run synaptic as normal (not root) user, as usual, like that (from command line):
Hope this helps.
--
notes:
1) please update the subject of the first post from "Debian 12.9 in VBox. What is going on here?" to "Synaptic with Debian 12.9: please restart your session without Wayland, or run Synaptic without root permission"
2) discussion moved from "Installation" to "Beginners Questions"
--
[1]
synaptic/0.91.5/gtk/gsynaptic.cc/#L410
[2]
Gtkinit_check
[3]
gtk_init_check source code
[4]
gdk_display_open_default_libgtk_only source code
[5]
gdk_display_open source code