Difference between revisions of "Flatpak"

From GnuCash
Jump to: navigation, search
(Revview and sync with de version)
m (Known Issues: more drastic header)
Line 15: Line 15:
 
* no ''direct report printing'', but printing them to file and direct printing of checks works and  
 
* no ''direct report printing'', but printing them to file and direct printing of checks works and  
  
;Upgrading from flatpak GnuCash 4.4 or earlier to flatpak GnuCash 4.5 or later: Due to changes internal to flatpak your GnuCash preferences will be reset. We have created a fix for this in GnuCash 4.7. Unfortunately this fix can only work if you have run GnuCash 4.7 (or more recent) at least once natively on your host system before running GnuCash 4.7 or more recent in flatpak. This is currently (at the time of the 4.7 release) unlikely to be possible but the situation will improve over time.
+
;Potential loss of Settings while upgrading your flatpak from GnuCash ≤ 4.4 to GnuCash ≥ 4.5: Due to changes internal to flatpak your GnuCash preferences will be reset. We have created a fix for this in GnuCash 4.7. Unfortunately this fix can only work if you have run GnuCash 4.7 (or more recent) at least once natively on your host system before running GnuCash 4.7 or more recent in flatpak. This is currently (at the time of the 4.7 release) unlikely to be possible but the situation will improve over time.
  
In case you hit this issue there are a few ways forward:
+
:In case you hit this issue there are a few ways forward:
 
:* If you can run GnuCash 4.7+ natively on your host and you have installed GnuCash flatpak 4.7+
 
:* If you can run GnuCash 4.7+ natively on your host and you have installed GnuCash flatpak 4.7+
 
::* do run GnuCash 4.7+ natively at least once and
 
::* do run GnuCash 4.7+ natively at least once and
Line 26: Line 26:
 
::* you can run the following commands in a shell: {{Flatpak convert-pref.sh}}
 
::* you can run the following commands in a shell: {{Flatpak convert-pref.sh}}
  
For the nitty-gritty details that causes this issue, refer to [https://bugs.gnucash.org/show_bug.cgi?id=798194 Bug 798194]
+
:For the nitty-gritty details that causes this issue, refer to [https://bugs.gnucash.org/show_bug.cgi?id=798194 Bug 798194]
  
 
;Ubuntu derivates: It was only reported by their users. A bug that causes guile to attempt to recompile all scm sources: {{Flatpak_Guile_Error_Demo}}
 
;Ubuntu derivates: It was only reported by their users. A bug that causes guile to attempt to recompile all scm sources: {{Flatpak_Guile_Error_Demo}}

Revision as of 21:03, 19 October 2021

Languages Deutsch

Flatpaks are bundles which besides the program also contain all required libraries. Use cases:

  • If your Linux distribution is too old to offer all required libraries but has Flatpak support, you can install a recent released version of GnuCash from the FlatHub repository.
  • If a developer asks you to test a patch, you can use a nightly version from our Flatpak repository.

Note flatpak's Sandbox concept: it uses files in

$HOME/.var/app/org.gnucash.GnuCash/ and
$HOME/.local/share/flatpak/app/org.gnucash.GnuCash/

Known Issues

  • We do not ship the Python Bindings,
  • no direct report printing, but printing them to file and direct printing of checks works and
Potential loss of Settings while upgrading your flatpak from GnuCash ≤ 4.4 to GnuCash ≥ 4.5
Due to changes internal to flatpak your GnuCash preferences will be reset. We have created a fix for this in GnuCash 4.7. Unfortunately this fix can only work if you have run GnuCash 4.7 (or more recent) at least once natively on your host system before running GnuCash 4.7 or more recent in flatpak. This is currently (at the time of the 4.7 release) unlikely to be possible but the situation will improve over time.
In case you hit this issue there are a few ways forward:
  • If you can run GnuCash 4.7+ natively on your host and you have installed GnuCash flatpak 4.7+
  • do run GnuCash 4.7+ natively at least once and
  • (re)move the file $HOME/.var/app/org.gnucash.GnuCash/config/glib-2.0/settings/keyfile. The next time you start GnuCash flatpak it will import your preferences from your host GnuCash.
  • If you're not in a position you can run GnuCash 4.7+ natively on your host and you didn't tweak a lot of preferences
  • the easiest fix then is probably to manually go through and set the preferences you tweaked before the first time you start flatpak GnuCash 4.5 or above. They should stay set after that.
  • If you do want to restore your preferences while not able to run GnuCash 4.7+ natively on your host
  • you can run the following commands in a shell:
    # Backup your current sandbox settings:
    cp $HOME/.var/app/org.gnucash.GnuCash/config/glib-2.0/settings/keyfile \
      $HOME/gnucash-settings.save
    # Real conversion:
    dconf dump /org/gnucash/ > \
      $HOME/.var/app/org.gnucash.GnuCash/config/glib-2.0/settings/keyfile
    perl -pi.bkp -e's!^[[]![org/gnucash/!' \
      $HOME/.var/app/org.gnucash.GnuCash/config/glib-2.0/settings/keyfile
    
For the nitty-gritty details that causes this issue, refer to Bug 798194
Ubuntu derivates
It was only reported by their users. A bug that causes guile to attempt to recompile all scm sources:
:
;;; note: source file /app/share/guile//2.2/ice-9/eval.scm
;;;       newer than compiled /app/lib/guile/2.2/ccache/ice-9/eval.go
:
Workaround:
# --system install
cd /var/lib/flatpak/app/org.gnucash.GnuCash
# OR --user install
cd $HOME/.local/share/flatpak/app/org.gnucash.GnuCash

sudo find . -name '*.go' -exec touch '{}' ';'

Resolved

Installation

You can configure many package managers like Gnome Software or KDE's Discover to at least install or update Flatpaks from Flathub, but on this page we will use the more powerful flatpak command line tool. The examples to install flatpak itself are written for Debian (in Buster Flatpak is already included, for Stretch and Jessie backports exist) and its derivates like Ubuntu.

Hint
For other distributions replace apt* <command> by your preferred commandline software managment tool and its command, i.e. for many rpm based distributions
zypper install flatpak
FlatPak.org offers Instructions for several distributions.

Regular releases at flathub.org

You can have both the regular, currently GnuCash 5.9, and beta branches installed at the same time.

Note
The current versions contain Aqbanking 6.5.4.

Betas (GnuCash 5.9xx) are previews and only released in the last months before the next main version, see Release Schedule.

See also Flathub
For Stable Releases
# Install FlatPak (on debian based distributions, others have to replace 'apt-get install'):
sudo apt-get install flatpak

# Register FlatHub repository for a system app (available to all users):
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# or only you:
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

# Install GnuCash ...
# for all users:
#  sudo is only needed for a --system install, if the user is not in the 'sudo' group
#  --system is the default if --user is not specified
sudo flatpak install --system flathub org.gnucash.GnuCash
# or only you:
flatpak install --user flathub org.gnucash.GnuCash

# Run GnuCash:
flatpak run org.gnucash.GnuCash
Default App Installation Locations
  --system (all users)    /var/lib/flatpak
  --user                  ~/.local/share/flatpak
Tip
To get the most recent version, run each quarter year (see Release Schedule):
flatpak update
For Unstable (i.e., beta) Releases
Do the process for stable releases, but register, install, and run as follows.
# Register:
flatpak remote-add --user --if-not-exists flathub https://flathub.org/beta-repo/flathub-beta.flatpakrepo
# Install
flatpak install --user flathub-beta org.gnucash.GnuCash
# Run
flatpak run --branch=beta org.gnucash.GnuCash
Downgrading
It can't be done from the average package manager, but it can be done from the command line. It's a two-step command:
flatpak remote-info --log flathub org.gnucash.GnuCash # list all commits in the repo
flatpak update --commit=HASH org.gnucash.GnuCash # checkout commit HASH in the repo
The only gotcha is that if you have more than one repo that has org.gnucash.GnuCash I haven't found a way to tell the command which repo you want to manipulate. It seems flatpak will update all installed versions. If you have one app installed from our nightlies and one from flathub, the above command will fail as only the flathub repo will have the proper commit hash.

Nightly Test Versions at gnucash.org

Warning
Save your data before using test versions!

Often you can find test versions on the build-server. They come in two flavours:

Maint
Version 5.9 plus all recent bug fixes, but no new features: code.gnucash.org/builds/flatpak/maint/
Master
Version 5.9 plus new features, but bug fixes can be delayed a few days: code.gnucash.org/builds/flatpak/master/
Tip
The file names in these directories can be used in the example below after trimming the „gnucash-“ prefix and „.flatpakref“ suffix.
Note
The current version contains Aqbanking 6.5.12beta.
sudo apt install flatpak  #install Flatpak
# register repositories:
sudo flatpak remote-add --if-not-exists gnucash https://code.gnucash.org/builds/flatpak/gnucash-nightlies.flatpakrepo
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --arch=x86_64 remote-ls gnucash  # show all packages
# output should be:
# org.gnucash.GnuCash
# org.gnucash.GnuCash.Debug
# org.gnucash.GnuCash.Locale
sudo flatpak --arch=x86_64 install gnucash org.gnucash.GnuCash//maint-C3.8b-163-g0e6c9e219-D3.8b-15-g0479ece  # <-- change version here!
flatpak run org.gnucash.GnuCash  # start program
Note
flatpak --arch=x86_64 is only required, if you have a 64-bit processor with a 32-bit OS.

Configuration

Granting Access to Other Resources

As each Flatpak app runs in a sandbox, you have to unloock additionally required resources like

USB Drive
# After configuring automatic mounting of the drive in the host system
sudo flatpak override org.gnucash.GnuCash --filesystem=$PATH_TO_DRIVE
Smartcard Reader
To use smart cards in AqBanking
  1. on the host—your Linux PC—the demon pcscd must be running,
  2. the related socket must become unlocked for your GnuCash-Flatpak once:
    sudo flatpak override org.gnucash.GnuCash --socket=pcsc
    

If sudo is required depends on the rest of your installatiom.

See also
https://docs.flatpak.org/en/latest/en/latest/sandbox-permissions.html

Changing the Locale

Refer to Locale Settings to determine the settings required.

Refer to Configuration Locations - System-wide for instructions on how to change Flatpak environment variables using flatpak override.

Tips

Getting Console Output

In case of trouble get the console output:
flatpak run org.gnucash.GnuCash
or even better
flatpak run org.gnucash.GnuCash --logto stdout

The latter will print all logs to the console rather than to an inaccessible trace file.

Using Command Line Tools

To call command line tools like aqbanking-cli, the following opens a command shell inside the sandbox of GnuCash.
flatpak run --command=sh org.gnucash.GnuCash

Inside you can call related shell commands for Online Banking like aqbanking-cli… or Online Quotes gnc-fq-* etc.

The following enters the GnuCash sandbox and runs a gnucash-cli command in a single line (using the example of getting price quotes). This can be useful for automation, i.e. creating a modern systemd timer or a classical cron job to get price quotes on a regular basis.
flatpak run --command=gnucash-cli org.gnucash.GnuCash --quotes get /path/to/file.gnucash

Notice the order of the arguments!

SQL Connection

Use 127.0.0.1 instead of localhost. The latter will tell the mysql client to use unix file sockets. These are not permitted by default by the flatpak sandbox. You can enable permissions for this on your gnucash flatpak, though I don't know offhand where the unix socket is located. You'll have to figure that out first (it will look like a file on your system somewhere) and then use the flatpak override commmand to tell it to allow access to that file for the org.gnucash.GnuCash package.

Using 127.0.0.1 on the other hand will force mysql to use a real network connection. Those are not restricted in the GnuCash flatpak.

More details: FlatHub GnuCash issue 17

Maintenance

You should — also if no new GnuCash version was announced — sometimes run
sudo flatpak update  # sudo is only required for systemwide installations
to look for updated components of your Flatpak environment. That might look like:
        ID                                    Zweig  Op  Remote   Download
 1.     org.freedesktop.Platform.GL.default   19.08  u   flathub   < 85,1 MB
 2.     org.freedesktop.Platform.VAAPI.Intel  19.08  u   flathub    < 8,7 MB
 3.     org.gnome.Platform.Locale             3.34   u   flathub  < 322,2 MB (partial)
 4.     org.gnome.Platform                    3.34   u   flathub  < 320,4 MB
 5.     org.gnome.Sdk.Locale                  3.34   u   flathub  < 325,8 MB (partial)
 6.     org.gnome.Sdk                         3.34   u   flathub  < 663,9 MB

Proceed with these changes to the user installation? [Y/n]:
It is primarly important, if you reported a problem about which the Gnucash-Developers said, its cause lies not in Gnucash but one of the by Flatpak installed Gnome libraries. But also for security reasons you should keep your environment up to date.
Note
You can learn more about the Available Runtimes, Sandbox Permissions Reference

Crash: Stacktrace

$ flatpak-coredumpctl --help
usage: Debug in gdb an application that crashed inside flatpak. It uses (and thus requires) coredumpctl to retrieve the coredump file.
       [-h] [-b BUILD_DIRECTORY] [--extra-flatpak-args EXTRA_FLATPAK_ARGS] [-m [COREDUMPCTL_MATCHES]]
       [--gdb-arguments GDB_ARGUMENTS]
       [app]

positional arguments:
  app                   The flatpak application to use. eg. `org.gnome.Epiphany//3.28`.

optional arguments:
  -h, --help            show this help message and exit
  -b BUILD_DIRECTORY, --build-directory BUILD_DIRECTORY
                        The build directory to use. It allows you to retrieve a coredump for applications being built
  --extra-flatpak-args EXTRA_FLATPAK_ARGS
                        Extra argument to pass to flatpak
  -m [COREDUMPCTL_MATCHES], --coredumpctl-matches [COREDUMPCTL_MATCHES]
                        Coredumpctl matches, see `man coredumpctl` for more information.
  --gdb-arguments GDB_ARGUMENTS
                        Arguments to pass to gdb.

For other debug options see Debugging.

GTK Inspector

flatpak run --env=GTK_DEBUG=interactive org.gnucash.GnuCash

Other

Migration from normal package to flatpak (german)