Error with gnome-sdk gjs

I am trying to help the foliate upstream maintain and upkeep the foliate snap as they were going to ditch it due to build errors etc. As my first step i upgraded the existing foliate snap yaml to core 22 from core18, plus since foliate github repos current main branch is for the upcoming dev version, i changed the source to a tar file of the latest stable release here is the error i get afte building it with above mods, i have kept the snap use gjs from gnome-sdk through layouts but the snap builds but wont run, producing the following error ;

(gjs:9140): Gjs-ERROR 11:14:34.073: JS ERROR: Error: Requiring GjsPrivate, version none: Typelib file for namespace ‘GjsPrivate’ (any version) not found require@resource:///org/gnome/gjs/modules/esm/gi.js:14:24 @gi://GjsPrivate:3:25

Trace/breakpoint trap (core dumped)

Here is the prototype as proposed ;

You need to set GI_TYPELIB_PATH to include the location of the GjsPrivate typelib. Also note you are renaming the snap in your yaml from what’s published and it doesn’t match the path in your prefix. To fix the typelib issue:

  • environment:
  •  GI_TYPELIB_PATH: $SNAP/gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET/girepository-1.0:$SNAP/gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET/gjs/girepository-1.0

Thanks for checking it out, I renamed it for testing purposes, i will actually restore the name etc. to original values once its successfully build.

I am having some similar problems with celluloid regarding the sdk, it always give this error, can you give me some insight on this ??

/snap/celluloid/3/usr/bin/celluloid: symbol lookup error: /snap/celluloid/3/gnome-platform/usr/lib/x86_64-linux-gnu/libpango-1.0.so.0: undefined symbol: hb_ot_color_has_paint

The celluloid error is because you are staging something that depends on a different harfbuzz. You should look at the libs that are bundled in your snap and removed things that aren’t needed.

Can you recheck the proposed YAML and ensure i have done everything alright ?? I think desktop file should be added but it wasnt present in the original yaml

This is the new error, after adding that env variable ;

(com.github.johnfactotum.Foliate:12782): Gjs-CRITICAL 12:24:36.087 JS ERROR: ImportError: No JS module ‘main’ found in search path@/snap/foliate-gtk/6/usr/bin/com.github.johnfactotum.Foliate:9:1

(com.github.johnfactotum.Foliate:12782): Gjs-CRITICAL : 12:24:36.087: Script /snap/foliate-gtk/6/usr/bin/com.github.johnfactotum.Foliate threw an exception

Anything to be staged ??

This yaml works fine for me:

name: foliate
grade: stable
version: '2.5.4'
summary: Foliate is a Simple Yet Powerful  E-Book Reader built in Gtk.
description: |
  Simple, Advanced and Lightweight Ebook Reader.
license: GPL-3.0+
base: core22
confinement: strict
compression: lzo
architectures:
  - build-on: [amd64]
    build-for: [amd64]
layout:
  /usr/lib/$CRAFT_ARCH_TRIPLET/espeak-ng-data:
    symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/espeak-ng-data
  /usr/bin/gjs:
    symlink: $SNAP/gnome-platform/usr/bin/gjs

slots:
  dbus-daemon:
    interface: dbus
    bus: session
    name: com.github.johnfactotum.Foliate

apps:
  foliate:
    command: usr/bin/com.github.johnfactotum.Foliate
    extensions: [gnome]
    plugs:
      - network
      - audio-playback
      - removable-media
    slots:
      - dbus-daemon
    common-id: com.github.johnfactotum.Foliate
    environment:
      GI_TYPELIB_PATH: $SNAP/gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET/girepository-1.0:$SNAP/gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET/gjs/girepository-1.0

parts:
  foliate:
    plugin: meson
    source: https://github.com/johnfactotum/foliate/archive/refs/tags/2.6.4.tar.gz
    meson-parameters: [--prefix=/snap/foliate/current/usr]
    override-pull: |
      craftctl default
      sed -i -e 's|@GJS@|/usr/bin/gjs|g' src/com.github.johnfactotum.Foliate.in
    build-packages:
      - git
      - libgjs-dev
      - build-essential
      - xmlstarlet 
    parse-info: [usr/share/metainfo/com.github.johnfactotum.Foliate.appdata.xml]
    organize:
      snap/foliate/current/usr: usr
      
  tts:
    plugin: nil
    stage-packages:
      - espeak-ng
      - speech-dispatcher-espeak-ng
      - libaudio2
      - libsndio7.0

Ok will try building with this and once assured i will request the upstream to do the same

This isnt the case in mine, am using Lubuntu 22.04, and using the yaml as approved by you, gives the following error when triggering from terminal, is this problem distro specific ?? (I am building the snap as foliate-gtk for test purposes)

(com.github.johnfactotum.Foliate:8826): Gjs-CRITICAL : 09:00:29.796: JS ERROR: ImportError: No JS module ‘main’ found in search path @/snap/foliate-gtk/7/usr/bin/com.github.johnfactotum.Foliate:9:1

(com.github.johnfactotum.Foliate:8826): Gjs-CRITICAL : 09:00:29.797: Script /snap/foliate-gtk/7/usr/bin/com.github.johnfactotum.Foliate threw an exception

I can see in your error you still have a mixture of using foliate and foliate-gtk. In what I pasted it was all using foliate.

I did change foliate to foliate-gtk before testing here is the yaml for better clarification ;

Exactly, you have a mix of foliate and foliate-gtk. Your prefix and organize lines weren’t changed to match. I don’t see the reason for testing it as a different snap name from what you have proposed to the snap maintainer. If they accept the change, you’ll need to ensure it’s named foliate and you’ll need thorough testing of what you are submitting.

Ok, got it, i will ensure all this errors gets fixed before submitting to the upstream

Update: It now works and i have submitted it to upstream, i also added the desktop file as the snap ran but no desktop file or entry was available in the menu

The snap is build and also the upstream has accepted it and published the latest revision to the snap store, only one to-do is to make the snap build for only three archs-arm(64 & hf) and amd64