89luca89 / distrobox

Use any linux distribution inside your terminal. Enable both backward and forward compatibility with software and freedom to use whatever distribution you’re more comfortable with. Mirror available at: https://gitlab.com/89luca89/distrobox
https://distrobox.it/
GNU General Public License v3.0
9.96k stars 410 forks source link

[Error] Exported app doesn't launch from host #299

Closed michallepicki closed 2 years ago

michallepicki commented 2 years ago

Describe the bug When exporting the code application (e.g. gedit) from an ubuntu box, the app doesn't launch on the host.

To Reproduce Create a new ubuntu:latest (22.04) box, enter and install gedit

# on the host:
cd && mkdir ubu && distrobox create --image ubuntu:latest --name ubu --home "$HOME/ubu"
distrobox-enter ubu

# inside container:
cd
sudo apt install -y gedit
distrobox-export --app gedit

The application file gets exported:

# on the host:
$ cat ~/.local/share/applications/ubu-org.gnome.gedit.desktop 
[Desktop Entry]
Name=Text Editor  (on ubu)
Comment=Edit text files
Exec=/var/home/michal/.local/bin/distrobox-enter -n ubu -- '  gedit  %U'
Terminal=false
Type=Application
StartupNotify=true
MimeType=text/plain;
# TRANSLATORS: Do NOT translate or transliterate this text!
#              This is an icon file name.
Icon=org.gnome.gedit
Categories=GNOME;GTK;Utility;TextEditor;
Actions=new-window;new-document;
# TRANSLATORS: Do NOT translate or localize the semicolons!
#              The list MUST also end with a semicolon!
#              Search terms to find this application.
Keywords=Text;Editor;Plaintext;Write;gedit;
DBusActivatable=true
X-Ubuntu-Gettext-Domain=gedit

[Desktop Action new-window]
Name=New Window  (on ubu)
Exec=/var/home/michal/.local/bin/distrobox-enter -n ubu -- '  gedit --new-window'

[Desktop Action new-document]
Name=New Document  (on ubu)
Exec=/var/home/michal/.local/bin/distrobox-enter -n ubu -- '  gedit --new-document'
StartupWMClass=gedit

but using the app doesn't launch it. The app starts correctly when started from within the box using gedit command.

Expected behavior The application window opens after using the exported shortcut

Logs

Exporting the app shows:

Click to open ``` # in the container: $ distrobox-export --app gedit --verbose + [ ! -f /run/.containerenv ] + id -u + [ 1000 -eq 0 ] + [ -z gedit ] + [ -n gedit ] + [ -n ] + [ -n gedit ] + [ -n ] + [ -n ] + [ -n ] + uname -n + cut -d. -f1 + container_name=ubu + container_command_prefix=/var/home/michal/.local/bin/distrobox-enter -n ubu -- ' + [ -z ] + exported_app_label= (on ubu) + export_application + grep -ril Exec=.*gedit /usr/share/applications/org.gnome.gedit.desktop /usr/share/applications/python3.10.desktop /usr/share/applications/xdg-desktop-portal-gtk.desktop /usr/share/applications/yelp.desktop /var/lib/flatpak/exports/share/applications/mimeinfo.cache /var/lib/flatpak/exports/share/applications/org.fedoraproject.MediaWriter.desktop /var/lib/flatpak/exports/share/applications/org.gnome.Calculator.desktop /var/lib/flatpak/exports/share/applications/org.gnome.Calendar.desktop /var/lib/flatpak/exports/share/applications/org.gnome.Characters.desktop /var/lib/flatpak/exports/share/applications/org.gnome.Connections.desktop /var/lib/flatpak/exports/share/applications/org.gnome.Contacts.desktop /var/lib/flatpak/exports/share/applications/org.gnome.Evince-previewer.desktop /var/lib/flatpak/exports/share/applications/org.gnome.Evince.desktop /var/lib/flatpak/exports/share/applications/org.gnome.Extensions.desktop /var/lib/flatpak/exports/share/applications/org.gnome.Logs.desktop /var/lib/flatpak/exports/share/applications/org.gnome.Maps.desktop /var/lib/flatpak/exports/share/applications/org.gnome.TextEditor.desktop /var/lib/flatpak/exports/share/applications/org.gnome.Weather.desktop /var/lib/flatpak/exports/share/applications/org.gnome.baobab.desktop /var/lib/flatpak/exports/share/applications/org.gnome.clocks.desktop /var/lib/flatpak/exports/share/applications/org.gnome.eog.desktop /var/lib/flatpak/exports/share/applications/org.gnome.font-viewer.desktop /var/lib/flatpak/exports/share/applications/org.libreoffice.LibreOffice.base.desktop /var/lib/flatpak/exports/share/applications/org.libreoffice.LibreOffice.calc.desktop /var/lib/flatpak/exports/share/applications/org.libreoffice.LibreOffice.desktop /var/lib/flatpak/exports/share/applications/org.libreoffice.LibreOffice.draw.desktop /var/lib/flatpak/exports/share/applications/org.libreoffice.LibreOffice.impress.desktop /var/lib/flatpak/exports/share/applications/org.libreoffice.LibreOffice.math.desktop /var/lib/flatpak/exports/share/applications/org.libreoffice.LibreOffice.writer.desktop /var/lib/flatpak/exports/share/applications/org.libreoffice.LibreOffice.xsltfilter.desktop + desktop_files=/usr/share/applications/org.gnome.gedit.desktop + [ -z /usr/share/applications/org.gnome.gedit.desktop ] + icon_files= + grep Icon= /usr/share/applications/org.gnome.gedit.desktop + cut -d= -f2- + icon_name=org.gnome.gedit + [ -e org.gnome.gedit ] + find /usr/share/icons /usr/share/pixmaps /var/lib/flatpak/exports/share/icons -iname *org.gnome.gedit* + icon_files= /usr/share/icons/hicolor/scalable/apps/org.gnome.gedit.svg /usr/share/icons/hicolor/symbolic/apps/org.gnome.gedit-symbolic.svg + mkdir -p /run/host/var/home/michal/.local/share/applications + icon_file_absolute_path= + dirname /usr/share/icons/hicolor/scalable/apps/org.gnome.gedit.svg + sed s|/usr/share/|\/run\/host\//var/home/michal/.local/share/|g + sed s|/var/lib/flatpak/exports/share|\/run\/host\//var/home/michal/.local/share/|g + sed s|pixmaps|icons|g + icon_home_directory=/run/host//var/home/michal/.local/share/icons/hicolor/scalable/apps + dirname /usr/share/icons/hicolor/scalable/apps/org.gnome.gedit.svg + [ /run/host//var/home/michal/.local/share/icons/hicolor/scalable/apps = /usr/share/icons/hicolor/scalable/apps ] + [ 0 -ne 0 ] + mkdir -p /run/host//var/home/michal/.local/share/icons/hicolor/scalable/apps + cp -r /usr/share/icons/hicolor/scalable/apps/org.gnome.gedit.svg /run/host//var/home/michal/.local/share/icons/hicolor/scalable/apps + dirname /usr/share/icons/hicolor/symbolic/apps/org.gnome.gedit-symbolic.svg + sed s|/usr/share/|\/run\/host\//var/home/michal/.local/share/|g + sed s|/var/lib/flatpak/exports/share|\/run\/host\//var/home/michal/.local/share/|g + sed s|pixmaps|icons|g + icon_home_directory=/run/host//var/home/michal/.local/share/icons/hicolor/symbolic/apps + dirname /usr/share/icons/hicolor/symbolic/apps/org.gnome.gedit-symbolic.svg + [ /run/host//var/home/michal/.local/share/icons/hicolor/symbolic/apps = /usr/share/icons/hicolor/symbolic/apps ] + [ 0 -ne 0 ] + mkdir -p /run/host//var/home/michal/.local/share/icons/hicolor/symbolic/apps + cp -r /usr/share/icons/hicolor/symbolic/apps/org.gnome.gedit-symbolic.svg /run/host//var/home/michal/.local/share/icons/hicolor/symbolic/apps + basename /usr/share/applications/org.gnome.gedit.desktop + desktop_original_file=org.gnome.gedit.desktop + basename /usr/share/applications/org.gnome.gedit.desktop + desktop_home_file=ubu-org.gnome.gedit.desktop + [ 0 -ne 0 ] + sed s|^Exec=|Exec=/var/home/michal/.local/bin/distrobox-enter -n ubu -- ' |g /usr/share/applications/org.gnome.gedit.desktop + sed s|\(%.*\)| \1|g + sed s|^Exec=.*|&'|g + sed s|^TryExec=.*|TryExec=true|g + sed s|Name.*|& (on ubu)|g + grep -q StartupWMClass /run/host/var/home/michal/.local/share/applications/ubu-org.gnome.gedit.desktop + printf StartupWMClass=%s\n gedit + [ -n ] + sed -i s|/usr/share/|\/run\/host/var/home/michal/.local/share/|g /run/host/var/home/michal/.local/share/applications/ubu-org.gnome.gedit.desktop + sed -i s|pixmaps|icons|g /run/host/var/home/michal/.local/share/applications/ubu-org.gnome.gedit.desktop + [ 0 -ne 0 ] + printf Application %s successfully exported.\nOK!\n gedit Application gedit successfully exported. OK! + printf %s will appear in your applications list in a few seconds.\n gedit gedit will appear in your applications list in a few seconds. + [ 0 -ne 0 ] ```

When I try to run it from terminal (I think that's the way to do it?) I see this log but nothing happens, the app doesn't open:

# on the host:
$ gtk-launch ubu-org.gnome.gedit

(gtk-launch:82093): GLib-GIO-CRITICAL **: 10:53:50.108: g_dbus_connection_call_sync_internal: assertion 'object_path != NULL && g_variant_is_object_path (object_path)' failed

Desktop (please complete the following information):

misobarisic commented 2 years ago

Running this from the terminal will work /var/home/michal/.local/bin/distrobox-enter -n ubu -- ' gedit %U'. I belive your gtk-launch command is trying to find gedit on the host machine and that's why the path assertion fails, it could not find an installation of gedit.

michallepicki commented 2 years ago

Hi @misobarisic , thanks for the info.

Running this from the terminal will work /var/home/michal/.local/bin/distrobox-enter -n ubu -- ' gedit %U'.

Yes, it works (opens a new file called %U but more or less works).

I'm trying to debug why the application doesn't start from the menu, that's why I tried gtk-launch, to get logs of what happens when I try to open the app from the host menu, to see why it gets stuck there. If there's a different way to mimic that I can try a different command.

Edit: When I try an app that doesn't exist on the host I get a different error:

$ gtk-launch nonexisting
gtk-launch: no such application nonexisting

So I think that having a desktop file in $HOME/.local/share/applications and seeing a different log means that it can find it and tries to start it, but please correct me if I'm wrong.

misobarisic commented 2 years ago

There is also the possibility of using distrobox-export --bin ... which allows you to export gedit from inside the container to ~/.local/bin on the outside making you able to just run gedit on the host

89luca89 commented 2 years ago

@michallepicki I've created a PR that should fix this

I've tested with your commands setup and it's working now can you also verify?

(remember that you can put the new distrobox-export somewhere else and call it with a complete path to test)

michallepicki commented 2 years ago

@89luca89 I tested #300 and it looks good, it fixes the issue. Thank you!

89luca89 commented 2 years ago

Perfect!