Sharing flatpak apps offline

Flatpak being cross-platform would seem like a good infrastructure for distributing applications offline.

Before screaming “just stay away from flatpak, bro” I know. But for the sole reason above, I went out experimenting with it to put a whole bunch of apps on a local flatpak repo on a removable media, and install them on another system.

I looked up USB Drives - Flatpak documentation and following the exact steps there, got me nowhere. I mean, while it is clear how to make a local repo with flatpak create-usb command (which may I add, has nothing to do with a USB and you can use it on any directory anywhere), it is absolutely not clear how to use it on the target system to install apps. The doc says: $ flatpak install --sideload-repo=/media/user/FLATPAKS/.ostree/repo flathub org.gnome.gedit is how you do it (with flatpak 1.8.0 and above), but what happens when you do that is it goes ONLINE to get a repo summary from flathub, and then download apps from there, even when you make sure all the apps/runtimes you’ve put in the repo using flatpak create-usb are up to date. Worse yet, it just throws an error when offline, saying failed to get summary from flathub.

Getting a little deeper into the documentation, I did the struggle as follows, Basically trying to actually add the local repo made by create-usb using flatpak remote-add.

$ flatpak --version
Flatpak 1.18.2
$ flatpak --verbose create-usb FlatRepo $(flatpak list --columns=ref)
# Too much stuff
$ ostree summary -u --repo=/run/media/rubi/Ventoy/Flatpak-repo/.ostree/repo
# No output
$ flatpak remote-ls file:///run/media/rubi/Ventoy/Flatpak-repo/.ostree/repo
Name                       Application ID                                             Version           Branch
Dialect                    app.drey.Dialect                                                             stable
g4music                    com.github.neithern.g4music                                                  stable
Flatseal                   com.github.tchx84.Flatseal                                                   stable
VideoDownloader            com.github.unrud.VideoDownloader                                             stable
bottles                    com.usebottles.bottles                                                       stable
Calligraphy                dev.geopjr.Calligraphy                                                       stable
FlameGet                   io.github.C_Yassin.FlameGet                                                  stable
Cine                       io.github.diegopvlk.Cine                                                     stable
Hieroglyphic               io.github.finefindus.Hieroglyphic                                            stable
Warehouse                  io.github.flattool.Warehouse                                                 stable
varia                      io.github.giantpinkrobots.varia                                              stable
mecalin                    io.github.nacho.mecalin                                                      stable
mundi                      io.github.nacho.mundi                                                        stable
Glyph                      io.github.shonebinu.Glyph                                                    stable
Constrict                  io.github.wartybix.Constrict                                                 stable
metadatacleaner            io.gitlab.metadatacleaner.metadatacleaner                                    stable
Upscaler                   io.gitlab.theevilskeleton.Upscaler                                           stable
Gelly                      io.m51.Gelly                                                                 stable
devtoolbox                 me.iepure.devtoolbox                                                         stable
Gahshomar                  org.gahshomar.Gahshomar                                                      stable
PolyMC                     org.polymc.PolyMC                                                            stable
waywallen                  org.waywallen.waywallen                                                      stable
Transition                 page.codeberg.grinka.Transition                                              stable
LibreMenuEditor            page.codeberg.libre_menu_editor.LibreMenuEditor                              stable
TAP                        org.freedesktop.LinuxAudio.Plugins.TAP                                       25.08
swh                        org.freedesktop.LinuxAudio.Plugins.swh                                       25.08
i386                       org.freedesktop.Platform.Compat.i386                                         25.08
default                    org.freedesktop.Platform.GL.default                                          25.08
default                    org.freedesktop.Platform.GL.default                                          25.08-extra
default                    org.freedesktop.Platform.GL32.default                                        25.08
default                    org.freedesktop.Platform.GL32.default                                        25.08-extra
codecs-extra               org.freedesktop.Platform.codecs-extra                                        25.08-extra
i386                       org.freedesktop.Platform.codecs_extra.i386                                   25.08-extra
gnome platform             org.gnome.Platform                                                           49
gnome platform             org.gnome.Platform                                                           50
Breeze                     org.gtk.Gtk3theme.Breeze                                                     3.22
kde platform               org.kde.Platform                                                             5.15-25.08
kde platform               org.kde.Platform                                                             6.10
kde platform               org.kde.Platform                                                             6.11
gecko                      org.winehq.Wine.gecko                                                        stable-25.08
mono                       org.winehq.Wine.mono                                                         stable-25.08

$ ls /run/media/rubi/Ventoy/Flatpak-repo/.ostree/repo
config  extensions  objects  refs  state  summary  tmp
$ flatpak remote-add --no-gpg-verify usb file:///run/media/rubi/Ventoy/Flatpak-repo/.ostree/repo
$ flatpak remote-ls usb
# No output

# I tried copying Flatpak-repo to the target system and tried again. The result is same as above.

Does anyone have any idea what in the world is the correct way to do it?

Edit: $ flatpak install --sideload-repo=/run/media/ruby/Ventoy/Flatpak-repo/.ostree/repo com.usebottles.bottles (for example) would work on the computer that has made the local repo after removing com.usebottles.bottles when offline.
It does not however, work on another system, in my case, and a realistic one, with flatpak installed and flathub configured as a remote, but no apps or runtimes has ever been installed on.

I also find this stuff not very intuitive. One question, did you do this step on the “target” system as well as the one where you created the local repo?

flatpak remote-modify --collection-id=org.flathub.Stable flathub

Hi, thank you for responding. Yes I did set a collection ID on the target system after starting this discussion, but for some reason I did not try --sideload-repo afterwards until I read your response​:sweat_smile:

But still, flatpak remote-ls usb shows nothing, I did add the local repo with the name usb as mentioned above, so this to me looks like an unintentional behavior.

Thanks again for your enlightening response.

Welcome! One more related tip - you can add the option --no-pull to the flatpak install command to prevent it pulling anything from the internet.

This prevents flatpak sneakily downloading from the remote and bypassing your sideload repo, and is more convenient than disconnecting your network :grinning_face:

one more question, how would you see what apps and runtimes are on a local repo? I mean, you would already know since you would put them there in the first place, but still, is there a way to do that?

I don’t know a better way than what you already posted :grinning_face:

flatpak remote-ls file:///run/media/rubi/Ventoy/Flatpak-repo/.ostree/repo

It is a bit weird that on the one hand, remote-ls kind of works on the locally created repo. But on the other hand, that repo somehow isn’t a fully fledged remote, because the apps you install from it are treated as if they come from flathub (or whatever their source was on the machine where you created a local repo). And like you found, remote-add on the local repo doesn’t seem to give anything useful.