ubuntu / gnome-sdk

GNOME SDK/Platform snap
21 stars 23 forks source link

Wrong path for the python interpreter #223

Open sameersharma2006 opened 3 months ago

sameersharma2006 commented 3 months ago

Snapping snaps with gnome-46-2404 SDK , Results in the following error :

libpxbackend-1.0.so: cannot open shared object file: No such file or directory
Failed to load module: /home/abc/snap/thonny/common/.cache/gio-modules/libgiolibproxy.so
/snap/thonny/x1/gnome-platform/command-chain/desktop-launch: line 625: /snap/thonny/x1/usr/local/bin/thonny: cannot execute: required file not found

Reproducible in G4Music & Thonny. Using SDK & Snapcraft from edge channel.

AFAIK this is related with XKB libs.

Filed similar report under mesa-2404 snap bug tracker. https://github.com/canonical/mesa-2404/issues/3#issuecomment-2176014858

seb128 commented 3 months ago

Thank you for your bug report. Could you share the corresponding snapcraft.yaml?

sameersharma2006 commented 3 months ago

Sure,

1) G4music

name: g4music
base: core24
adopt-info: g4music
grade: stable
confinement: strict
compression: lzo
platforms:
  amd64:
  arm64:

slots:
  g4music:
    interface: dbus
    bus: session
    name: com.github.neithern.g4music
  mpris:
    name: G4Music

apps:
  g4music:
    command: usr/bin/g4music
    extensions: [gnome]
    plugs:
      - home
      - audio-playback
      - network
      - network-status
      - network-bind
      - unity7
      - screen-inhibit-control
      - removable-media
    slots:
      - mpris
    common-id: com.github.neithern.g4music
    desktop: usr/share/applications/com.github.neithern.g4music.desktop

parts:
  g4music:
    source: https://gitlab.gnome.org/neithern/g4music.git
    source-depth: 1
    source-tag: 'v3.7.1'
    plugin: meson
    parse-info: [usr/share/metainfo/com.github.neithern.g4music.appdata.xml]
    meson-parameters:
      - --prefix=/usr
      - --buildtype=release
    build-packages:
      - libgstreamer1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - cmake
    override-pull: |
      craftctl default
      sed -e 's|Icon=@app_id@|Icon=${SNAP}/usr/share/icons/hicolor/scalable/apps/com.github.neithern.g4music.svg|' -i data/app.desktop.in

2) Thonny

name: thonny
base: core24
adopt-info: appinfo
grade: stable
confinement: strict
compression: lzo
platforms:
  amd64:
  arm64:

slots:
  thonny:
    interface: dbus
    bus: session
    name: org.thonny.Thonny

apps:
  thonny:
    command: usr/local/bin/thonny
    extensions: [gnome]
    common-id: org.thonny.Thonny
    environment:
      PYTHONPATH: ${SNAP}/lib/python3.12/site-packages:${SNAP}/usr/lib/python3.12/site-packages:${SNAP}/usr/local/lib/python3.12/dist-packages
    plugs:
      - home
      - unity7
      - network
      - network-bind
      - network-status
      - audio-playback
      - audio-record
      - bluez
      - camera
      - hardware-observe
      - system-observe
      - upower-observe
      - raw-usb
      - udisks2
      - optical-drive
      - removable-media
      - screen-inhibit-control
    desktop: appinfo/org.thonny.Thonny.desktop

parts:
  thonny:
    plugin: nil
    override-build: |
      craftctl default
      pip install --prefix=$CRAFT_PART_INSTALL/usr thonny==4.1.4

  appinfo:
    source: https://github.com/thonny/thonny.git
    source-tag: v4.1.4
    after: [thonny]
    parse-info: [packaging/linux/org.thonny.Thonny.appdata.xml]
    plugin: dump
    override-pull: |
      craftctl default
      sed -e 's|Exec=/usr/bin/thonny %F|Exec=/usr/local/bin/thonny %F|' -i packaging/linux/org.thonny.Thonny.desktop
      sed -e 's|Icon=thonny|Icon=${SNAP}/appinfo/thonny-256x256.png|' -i packaging/linux/org.thonny.Thonny.desktop
      mkdir appinfo
      cp packaging/linux/org.thonny.Thonny.desktop appinfo
      cp packaging/icons/thonny-256x256.png appinfo
    prime:
      - appinfo

  tkinter:
    after: [appinfo]
    plugin: nil
    stage-packages:
      - python3-tk
    prime:
      - -usr/lib/libBLTlite.2.5.so*

  deps:
    after: [tkinter]
    plugin: nil
    stage-packages:
      - libnotify-bin
      - zenity
      - xclip
    prime:
      - usr/bin/xclip*
      - usr/bin/zenity
      - usr/bin/notify-send
      - usr/lib/*/libXt.so*
      - usr/lib/*/libXmu.so*
      - usr/lib/*/libXext.so*

  cleanup:
    after: [deps]
    plugin: nil
    build-snaps: [core24, gnome-46-2404]
    override-prime: |
      set -eux
      for snap in "core24" "gnome-46-2404"; do
        cd "/snap/$snap/current" && find . -type f,l -exec rm -rf "${CRAFT_PRIME}/{}" \;
      done
  1. Curtail
    
    name: curtail
    base: core24
    adopt-info: curtail
    grade: stable
    confinement: strict
    compression: lzo
    platforms:
    amd64:
    arm64:

slots: curtail: interface: dbus bus: session name: com.github.huluti.Curtail

apps: curtail: command: usr/bin/curtail extensions: [gnome] environment: PYTHONPATH: ${SNAP}/usr/lib/python3/dist-packages:$PYTHONPATH XKB_CONFIG_ROOT: $SNAP/usr/share/X11/xkb plugs:

parts: curtail: source: https://github.com/Huluti/Curtail.git source-tag: '1.10.0' source-depth: 1 plugin: meson parse-info: [usr/share/metainfo/com.github.huluti.Curtail.appdata.xml] meson-parameters:

The reason i consider this a bug/issue is that previously i never staged xkbcommon libs & set its path manually with core22.

seb128 commented 3 months ago

I tried thonny and it fails on an error

init_fs_encoding: failed to get the Python codec of the filesystem encoding
...
ModuleNotFoundError: No module named 'encodings'

Which is different from what is described there?

sameersharma2006 commented 3 months ago

@seb128 Surprisingly, the above doesn't come up in my Debian 12 system. It still reports the following;

update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/boot /boot none bind,ro 0 0): permission denied
/snap/thonny/x1/gnome-platform/command-chain/desktop-launch: line 625: /snap/thonny/x1/usr/local/bin/thonny: cannot execute: required file not found

Additionally, i have installed the thonny snap locally with --dangerous flag.

seb128 commented 3 months ago

/snap/thonny/x1/gnome-platform/command-chain/desktop-launch: line 625: /snap/thonny/x1/usr/local/bin/thonny: cannot execute: required file not found

ah, it worked here because I had gnome-46-2404-sdk installed

/snap/thonny/x1/usr/local/bin/thonny starts with that line

!/snap/gnome-46-2404-sdk/current/usr/bin/python3

Unsure what is defining the path to use for python3 there, maybe snapcraft?

sameersharma2006 commented 3 months ago

@seb128 Is the title valid, i mean i have literally the same problem in curtail & g4music. Should i open a different report for curtail & g4music ?

The error which pops up in curtail is bit different,

xkbcommon: ERROR: failed to add default include path /usr/share/X11/xkb
libpxbackend-1.0.so: cannot open shared object file: No such file or directory
Failed to load module: /home/abc/snap/curtail/common/.cache/gio-modules/libgiolibproxy.so
xkbcommon: ERROR: failed to add default include path /usr/share/X11/xkb
Segmentation fault

CC: https://github.com/canonical/mesa-2404/issues/3

seb128 commented 3 months ago

There is one issue with the python interpreter is about now.

Unsure about the xkbcommon issue but you opened another ticket already about that so we don't need to discuss it in this one

sergio-costas commented 3 months ago

I suspect that the python problem is due to pip install... If I'm right, it automagically creates the /usr/local/bin/thonny executable, and places in it a shebang with the path to the current python interpreter... which is the one in the SDK because it is running during building.

So the solution requires to manually "sed" that file after build and pip... something like

sed -i 's%#!%#!/usr/bin/env python3\n#%g' $CRAFT_PART_INSTALL/usr/local/bin/thonny

seb128 commented 3 months ago

Did you use gnome42 before and it was working or are those new snaps?

sameersharma2006 commented 3 months ago

All the snaps previously used core22, core18 & the gnome stack asaociated with them.

They all worked fine with core22/18 & gnome42/34 stack

On 5 July 2024 1:47:55 pm UTC, Sebastien @.***> wrote:

Did you use gnome42 before and it was working or are those new snaps?

-- Reply to this email directly or view it on GitHub: https://github.com/ubuntu/gnome-sdk/issues/223#issuecomment-2210911092 You are receiving this because you authored the thread.

Message ID: @.***>

seb128 commented 3 months ago

I don't think that statement is true. The version in the store works fine but /snap/thonny/217/bin/thonny is a bash script.

I cloned https://git.launchpad.net/thonny-snap , and try to build rev b7fe6ea2 (before the switch to core24), the resulting snap has

$ head /snap/thonny/x1/usr/local/bin/thonny
#!/snap/gnome-42-2204-sdk/current/usr/bin/python3

Checking the history you did switch from using the snapcraft python plugin to use the nil one and call pip manually which is more likely the change that introduced the problem

sameersharma2006 commented 3 months ago

Seems there is a bit of misunderstanding.

  1. When i say they previously worked fine with core22 etc. i meant all the snaps that i mentioned previously-g4music,curtail.
  2. Thonny snap never used core22 & never was it build from source, yes i have had experimental branches which tried do it with core22/core20 but failed.
  3. Thonny snap which exists in stable channel uses core18 & gnome-34 stack and uses upstream tar balls & doesn't involve using snapcraft python plugin as it involved dumping tar content.
  4. I switched to using pip since the upstream is depreciating its tar balls & building thonny from source in a confined snap doesn't work at-least in the many ways i tried.
  5. Hence to ensure thonny snap exists in the future , the pip method seems to be the feasible one as of now.