Adding optional library to GJS App

I’m trying to add an optional library— Ggit —to a Flatpak app prototype written in GJS, using Builder. However, when I run the application, I get the following error:

JS ERROR: Error: Requiring Ggit, version none: Typelib file for namespace 'Ggit' (any version) not found
require@resource:///org/gnome/gjs/modules/esm/gi.js:16:28

It seems like I’m missing a step to properly expose or include the Ggit introspection data. Could someone point out what I’m doing wrong?

Here’s the relevant part of my Flatpak json configuration:

{
...
"modules" : [
        {
            "name" : "test",
            "builddir" : true,
            "buildsystem" : "meson",
            "sources" : [
                {
                    "type" : "git",
                    "url" : "file:///home/user/Projects/test",
                    "branch": "main"
                }
            ]
        },
        {
            "name" : "libssh2",
            "buildsystem" : "cmake-ninja",
            "config-opts" : [
                "-DCMAKE_BUILD_TYPE=RelWithDebInfo",
                "-DCMAKE_INSTALL_LIBDIR:PATH=/app/lib",
                "-DBUILD_SHARED_LIBS:BOOL=ON"
            ],
            "cleanup" : [
                "/share/doc"
            ],
            "sources" : [
                {
                    "type" : "git",
                    "url" : "https://github.com/libssh2/libssh2.git",
                    "tag" : "libssh2-1.10.0"
                }
            ]
        },
        {
            "name" : "libgit2",
            "buildsystem" : "cmake-ninja",
            "config-opts" : [
                "-DCMAKE_BUILD_TYPE=RelWithDebInfo",
                "-DCMAKE_INSTALL_LIBDIR:PATH=/app/lib",
                "-DBUILD_SHARED_LIBS:BOOL=ON",
                "-DUSE_SSH:BOOL=ON",
                "-DUSE_THREADS:BOOL=ON"
            ],
            "sources" : [
                {
                    "type" : "git",
                    "url" : "https://github.com/libgit2/libgit2.git",
                    "tag" : "v1.6.4"
                }
            ]
        },
        {
            "name" : "libgit2-glib",
            "config-opts" : [
                "--buildtype=debugoptimized"
            ],
            "buildsystem" : "meson",
            "builddir" : true,
            "sources" : [
                {
                    "type" : "git",
                    "url" : "https://gitlab.gnome.org/GNOME/libgit2-glib.git",
                    "branch" : "master"
                }
            ]
        }
    ]
}

Have you tried putting your module (test) last in the declaration? They’re built in order :slight_smile:

1 Like

It’s works now :sweat_smile: Thank you for your advice!