GLib-GIO-ERROR **: Settings schema 'com.github.mfru.vala-todo' is not installed

1.6k Views Asked by At

First off, I am new to Vala, Gtk and Meson, so I might be looking in the totally wrong directions.

I'm running on Pop_OS! 20.10.

I want to compile a small example Vala application with support for GSettings.

However, when compiling with ninja, installing with sudo ninja install and then executing I get the error mentioned in the title.

It seems that even though my gschema file is copied into /usr/share/glib-2.0/schemas, running glib-compile-schemas in my post-install script is not doing anything.

I could also confirm that by running glib-compile-schemas manually and then checking with dconf Editor whether my settings are available which they aren't.

data/gschema.xml

<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
    <schema path="/com/github/mfru/vala-todo" id="com.github.mfru.vala-todo">
        <key name="pos-x" type="i">
            <default>360</default>
            <summary>Horizontal position</summary>
            <description>The saved horizontal position of our window</description>
        </key>

        <key name="pos-y" type="i">
            <default>360</default>
            <summary>Vertical position</summary>
            <description>The saved vertical position of our window</description>
        </key>

        <key name="window-width" type="i">
            <default>600</default>
            <summary>Window width</summary>
            <description>The saved width of our window</description>
        </key>

        <key name="window-height" type="i">
            <default>400</default>
            <summary>Window height</summary>
            <description>The saved height of our window</description>
        </key>
    </schema>
</schemalist>

data/meson.build

install_data(
    'gschema.xml',
    install_dir: join_paths (get_option ('datadir'), 'glib-2.0', 'schemas'),
    rename: meson.project_name () + '.geschema.xml'
)

meson/post-install.py

#!/usr/bin/env python3

import os
import subprocess

schemadir = os.path.join(os.environ['MESON_INSTALL_PREFIX'], 'share', 'glib-2.0', 'schemas')
print("Schemadir is", schemadir)

if 'DESTDIR' not in os.environ:
    print("Compiling the gsettings schemas...")
    subprocess.call(['glib-compile-schemas', schemadir])

I also reconfigured the meson prefix with meson build --prefix=/usr --reconfigure as at first the Prefix pointed to /usr/local but all existing schemas on my system are under /usr/share

Finally, what I expect to happen is that my example application starts without crashing because of missing GSettings.

Resources I looked into:

https://mesonbuild.com/Configuring-a-build-directory.html

https://developer.gnome.org/gio/stable/glib-compile-schemas.html

Is there any way to create GSettings schema during installation in Vala?

1

There are 1 best solutions below

0
On BEST ANSWER

You have a typo in your build.meson file.

It should be .gschema.xml instead of .geschema.xml.