Error in the guide "DBus and GVariant"
There a two problems in the example DBus and GVariant:
First:
const {GLib, Gio} = imports.gi.GLib;
should be changed to
const {GLib, Gio} = imports.gi;
And second, if I try to run you the following part of the example:
const {GLib, Gio} = imports.gi;
// This method takes three arguments. Remember that JavaScript has no tuple
// type so we're using an Array instead.
const parameters = new GLib.Variant('(ssa{sv})', [
'some-extension@someone.github.io',
'',
new GLib.Variant('a{sv}', {}),
]);
I get the following error:
gjs -m ./test.js
(gjs:297522): Gjs-CRITICAL **: 19:17:15.659: JS ERROR: TypeError: Object 0x2644eaad72e0 is not a subclass of GObject_Boxed, it's a GIRepositoryFunction
_packVariant@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:86:29
_packVariant@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:149:33
_packVariant@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:120:41
_packVariant@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:139:27
_init/this.Variant._new_internal@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:290:35
@file:///home/xyz/test.js:3:20
(gjs:297522): Gjs-CRITICAL **: 19:17:15.659: Module file:///home/xyz/test.js threw an exception
Maybe this should be changed just to:
const parameters = new GLib.Variant('(ssa{sv})', [
'some-extension@someone.github.io',
'',
{},
]);
I am on Fedora 36 and my Gjs version is:
gjs --version
gjs 1.72.0
Edited by Pascal Garber