1

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?

mfru
  • 473
  • 1
  • 3
  • 13
  • Are you sure that pop os looks for schemas in /usr/local? The glib-compile-schemas page says that it only looks under $XDG_DATA_DIRS, and /usr/local may not be there. – dcbaker Jun 29 '21 at 16:11
  • I might have worded that ambiguously: All schemas I could find were under `/usr/share/glib-2.0/schemas`, but the meson prefix initially pointed to `/usr/local` which lead to `glib-compile-schemas` not finding the schema because it is not listed in `$XDG_DATA_DIRS`. I did reconfigure the meson build prefix though, so my schema would actually be copied into the correct folder under `/usr/share` and it still seems to not compile it. (There is no output when running it, which I guess is normally a success?) – mfru Jun 30 '21 at 16:16
  • I'm not really a glib or schemas export (I am an upstream Meson dev though), python's `subprocess.call` doesn't raise an exception if something goes wrong, it returns the subprocess's return code, you may want to try changing the last line of your post install script to `sys.exit(subprocess.call(...))` and see if that fixes your issue. – dcbaker Jul 03 '21 at 04:15
  • I don't think it's that, I think it might be an issue with `glib-compile-schemas` itself. As I stated above, I even tried to run `glib-compile-schema` manually. (As in I copied the XML file into `/usr/share/glib-2.0/schemas` and inside the directory ran `sudo glib-compile-schemas .`) It did compile to a new `gschema.compiled` file, but neither is `dConf Editor` showing the settings nor is my program able to run due to still throwing the Glib-GIO-Error. – mfru Jul 05 '21 at 21:29

1 Answers1

0

You have a typo in your build.meson file.

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

mfru
  • 473
  • 1
  • 3
  • 13