Cannot load module /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so

Hello,
I’m building snap with desktop launcher on ubuntu 18.
It’s systray application and I always get this error message when I launch snap.
Do you have any clue for this issue?

The same issue in Simple-scan not working
Thank you.

Cannot load module /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so: /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so: undefined symbol: ibus_bus_get_service_name
/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so does not export GTK+ IM module API: /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so: undefined symbol: ibus_bus_get_service_name

My snapcraft.yaml

...
grade: stable
confinement: classic

base: core18
architectures:
  - build-on: amd64

apps:  
  cells-sync:
    command: bin/desktop-launch $SNAP/cells-sync start
    common-id: com.pydio.CellsSync.desktop
    desktop: usr/share/applications/com.pydio.CellsSync.desktop
    environment:
      CELLS_SYNC_IN_PATH: "true"
      TMPDIR: "$SNAP_USER_COMMON"
      LD_LIBRARY_PATH: "$SNAP/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/:$LD_LIBRARY_PATH"


parts:
  cells-part:
    # See 'snapcraft plugins'
    after:
    - desktop-gtk3
    plugin: dump
    source: src
    source-type: local
    prime:
    - -usr/share/icons
    override-build: |
      set -eu
      snapcraftctl build

      mkdir -pv $SNAPCRAFT_PART_INSTALL/usr/share/applications/      
      mkdir -pv $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps      
      cp ../src/cells-sync.desktop $SNAPCRAFT_PART_INSTALL/usr/share/applications/com.pydio.CellsSync.desktop
      cp ../src/cells-sync.png $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/cells-sync.png
      sed -i 's|^Icon=.*|Icon=\${SNAP}/usr/share/pixmaps/cells-sync\.png|g' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/com.pydio.CellsSync.desktop


  desktop-gtk3:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: gtk
    plugin: make
    make-parameters: ["FLAVOR=gtk3"]
    build-packages:
      - build-essential
      - libgtk-3-dev
    stage-packages:
      - libxkbcommon0  # XKB_CONFIG_ROOT
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libgtk-3-0
      - libgdk-pixbuf2.0-0
      - libglib2.0-bin
      - libgtk-3-bin
      - unity-gtk3-module
      - libappindicator3-1
      - locales-all
      - xdg-user-dirs
      - ibus-gtk3
      - libibus-1.0-5
      - fcitx-frontend-gtk3
      - libwebkit2gtk-4.0-37

This is a classic confinement issue. Your application is trying to load libraries from the wrong location, which is causing the warning you described in your post. To fix you need to remove or override the parts of LD_LIBRARY_PATH that point to /usr/lib because libraries found there are almost certain to cause issues with your app. Snapcraft should be setting the ELF headers’ RPATH feature but this might be being set to an incorrect value.

Hello,

Thanks for your reply.
I tried to print out the value of LD_LIBRARY_PATH and it actually does not content /usr/lib

For example:

LD_LIBRARY_PATH=/snap/cells-sync/x1/lib/x86_64-linux-gnu:/snap/cells-sync/x1/usr/lib:/snap/cells-sync/x1/usr/lib/x86_64-linux-gnu:/snap/cells-sync/x1/lib:/snap/cells-sync/x1/usr/lib/x86_64-linux-gnu/libunity

Hi,
I found that the error in this command in desktop-launch

Error: Cannot load module /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so: /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so: undefined symbol: ibus_bus_get_service_name
/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so does not export GTK+ IM module API: /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-ibus.so: undefined symbol: ibus_bus_get_service_name

==================
At the moment this line is executed, the variables are:
LD_LIBRARY_PATH: /snap/cells-sync/x1/lib/x86_64-linux-gnu:/snap/cells-sync/x1/usr/lib:/snap/cells-sync/x1/usr/lib/x86_64-linux-gnu:/snap/cells-sync/x1/lib:/snap/cells-sync/x1/usr/lib/x86_64-linux-gnu/libunity:/snap/cells-sync/x1/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules:/snap/cells-sync/x1/usr/lib/x86_64-linux-gnu/mesa:/snap/cells-sync/x1/usr/lib/x86_64-linux-gnu/mesa-egl:/snap/cells-sync/x1/usr/lib/x86_64-linux-gnu/dri:/var/lib/snapd/lib/gl

GTK_IM_MODULE_DIR: /home/user/snap/cells-sync/common/.cache/immodules
GTK_IM_MODULE_FILE: /home/user/snap/cells-sync/common/.cache/immodules/immodules.cache