Flatpak requires sudo to run applications [SOLVED]

I use the nix package manager to install new packages on an old Arch Linux installation that has not been upgraded in a long time. The package manager runs beautifully and even allowed me to install flatpak on this old system. The only problem is that flatpak applications only run with sudo:

$ which flatpak
/home/bruno/.nix-profile/bin/flatpak

$ flatpak run org.gnome.Recipes
bwrap: Creating new namespace failed, likely because the kernel does not support user namespaces.  bwrap must be installed setuid on such systems.
error: ldconfig failed, exit status 256

$ sudo flatpak run org.gnome.Recipes # this works

I tried making bwrap suid as suggested by the error message, but still no joy:

$ sudo chown -R bruno:root /nix/store/q67sv4bhq6snp4r6cbh79s9zknvqg78h-bubblewrap-0.3.0

$ sudo chmod -R u+s /nix/store/q67sv4bhq6snp4r6cbh79s9zknvqg78h-bubblewrap-0.3.0

$ flatpak run org.gnome.Recipes
bwrap: Creating new namespace failed, likely because the kernel does not support user namespaces.  bwrap must be installed setuid on such systems.
error: ldconfig failed, exit status 256

$ sudo flatpak run org.gnome.Recipes # this works

Does anybody know how to make “flatpak run” work without sudo in a nix environment? This machine has kernel 4.1.6 and I will upgrade it just in case it is the problem.

1 Like

I upgraded the linux kernel to 4.6.1, which came out after flatpak 0.99 (flatpak version in nix repository), and it made no difference.

Try this:

$ zcat /proc/config.gz | fgrep CONFIG_USER_NS
CONFIG_USER_NS=y

If you don’t get any output or CONFIG_USER_NS=n, then you need to recompile your kernel to enable it, if you want to avoid sudo.

$ zcat /proc/config.gz | fgrep CONFIG_USER_NS
# CONFIG_USER_NS is not set

Before recompiling kernel, I tried this:

$ sudo chown root:root /nix/store/q67sv4bhq6snp4r6cbh79s9zknvqg78h-bubblewrap-0.3.0/bin/bwrap
$ sudo chmod u+s /nix/store/q67sv4bhq6snp4r6cbh79s9zknvqg78h-bubblewrap-0.3.0/bin/bwrap
$ flatpak run org.foo.Bar # works!

I’ll mark as solved.

1 Like