NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.38k stars 13.6k forks source link

Bug: appimage-run fails to run any appimage #269721

Closed leg7 closed 2 days ago

leg7 commented 9 months ago

appimage-run cannot access my filesystem and fails to run any appimage because of this. I suspect this is due to me using impermanence and using bind mounts or something.

here is the log when trying to run an appimage:

[N] ~ $ appimage-run -d balenaEtcher-1.18.11-x64.AppImage                                                                                                                                         appimage-run-tests 
+ getopts x:w:dh option
+ shift 1
+ '[' -n '' ']'
++ realpath balenaEtcher-1.18.11-x64.AppImage
+ APPIMAGE=/nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ shift
+ '[' -n '' ']'
+ '[' -n true ']'
+ '[' -f /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage ']'
+ apprun
++ sha256sum /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk '{print $1}'
+ SHA256=f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ export APPDIR=/nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ APPDIR=/nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ '[' -x /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/squashfs-root ']'
+ '[' '!' -x /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50 ']'
++ dirname /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ mkdir -p /nix/persistent/home/user/.local/cache/appimage-run
mkdir: cannot create directory ‘/nix/persistent/home/user/.local/cache/appimage-run’: Read-only file system
+ unpack /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ local src=/nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ local out=/nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ local appimageSignature
++ LC_ALL=C
++ readelf -h /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk 'NR==2{print $10$11;}'
+ appimageSignature=4149
+ local appimageType
++ LC_ALL=C
++ readelf -h /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk 'NR==2{print $12;}'
+ appimageType=02
+ '[' 4149 '!=' 4149 ']'
+ case "$appimageType" in
++ LC_ALL=C
++ readelf -h /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk 'NR==13{e_shoff=$5} NR==18{e_shentsize=$5} NR==19{e_shnum=$5} END{print e_shoff+e_shentsize*e_shnum}'
+ offset=188392
++ basename /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ echo 'Uncompress balenaEtcher-1.18.11-x64.AppImage of type 02 @ offset 188392'
Uncompress balenaEtcher-1.18.11-x64.AppImage of type 02 @ offset 188392
+ unsquashfs -q -d /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50 -o 188392 /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage

FATAL ERROR: dir_scan: failed to make directory /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50, because No such file or directory
+ chmod go-w /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
chmod: cannot access '/nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50': No such file or directory
++ basename /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ echo 'balenaEtcher-1.18.11-x64.AppImage is now installed in /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50'
balenaEtcher-1.18.11-x64.AppImage is now installed in /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ export PATH=/nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin:/nix/store/1fn92b0783crypjcxvdv6ycmvi27by0j-binutils-2.40/bin:/nix/store/bblyj5b3ii8n6v4ra0nb37cmi3lf8rz9-coreutils-9.3/bin:/nix/store/7wfya2k95zib8jl0jk5hnbn856sqcgfk-gawk-5.2.2/bin:/nix/store/k93s5p63dsyyxih5lvl0mc6f0g7svbp7-libarchive-3.7.2/bin:/nix/store/sr6v1d6zyq1afwbbfryj2cyzh48p7g2v-pv-1.8.5/bin:/nix/store/325b9q4z86is6wzxqz59x3ik2ssfxa78-squashfs-4.6.1/bin:/run/wrappers/bin:/usr/bin:/usr/sbin:/nix/persistent/home/user/.local/share/opam/default/bin:/nix/store/kbcrs84s1x8yd5bp1nq6q6ihda8nd2lp-bash-interactive-5.2-p15/bin:/nix/store/ywwjpdyhar4f3vcqf4qk77vrbr3vj5wl-patchelf-0.15.0/bin:/nix/store/7wkshj58fcsl1f3zyi67qsxgl1p8nki1-gcc-wrapper-12.2.0/bin:/nix/store/dcd1zhv56rk0d2z7akzfjgzr076c4jl9-gcc-12.2.0/bin:/nix/store/lyvhsvwp2pzy74fkcn7qbs5vcgy5d7vl-glibc-2.37-8-bin/bin:/nix/store/ahkfdxq8mcpsb5kvdvgqr1wv8zjngbh4-coreutils-9.1/bin:/nix/store/rbwalnmk5a6nj9mbldxzmj11gvacbrsi-binutils-wrapper-2.40/bin:/nix/store/22p5nv7fbxhm06mfkwwnibv1nsz06x4b-binutils-2.40/bin:/nix/store/ahkfdxq8mcpsb5kvdvgqr1wv8zjngbh4-coreutils-9.1/bin:/nix/store/4qrbfa42xyicny7vlgbbqxz07kcsjbx2-findutils-4.9.0/bin:/nix/store/6bcqajyagcc4s3azx0zqnb3rqxd7gdnv-diffutils-3.9/bin:/nix/store/gy82r5cf12hgkmhzifsyx3fp6cnf6j2l-gnused-4.9/bin:/nix/store/zrls4w5lxynqakh1jlrp03kg4bxzp9yi-gnugrep-3.7/bin:/nix/store/s3yl3l8na93v53k2cfsyz0jrb50bnk8n-gawk-5.2.1/bin:/nix/store/czy796d2241296bdy45w87cmaiig50zr-gnutar-1.34/bin:/nix/store/hdbb5ayyrz1b5hicbsb4am8vin0xxxg6-gzip-1.12/bin:/nix/store/hd573q7097cxj5q29pnc3z0rvakz7ga3-bzip2-1.0.8-bin/bin:/nix/store/nnis9ph3wj866bbs0lalbf22i5bq8yry-gnumake-4.4.1/bin:/nix/store/rhvbjmcfnkg8i2dxpzr114cp1ws7f667-bash-5.2-p15/bin:/nix/store/x4ckkjsxfl4ihl82v0bzsyxs4ay2d5b5-patch-2.7.6/bin:/nix/store/8xjzmhw6hgqmynb5f1v7aw2lvafij405-xz-5.4.3-bin/bin:/nix/store/lcjsmsxqwd4vkq2wj5mmbyjzny3i6k49-file-5.44/bin:/nix/persistent/home/user/.local/share/opam/default/bin:/run/wrappers/bin:/nix/persistent/home/user/.local/bin:/nix/persistent/home/user/.nix-profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/etc/profiles/per-user/user/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/nix/store/1alqjnr40dsk7cl15l5sn5y2zdxidc1v-binutils-wrapper-2.40/bin:/nix/store/lvx8bvn5lc6aqjq2jalnq7xc9lhqbpzg-pciutils-3.10.0/bin:/nix/persistent/home/user/usr/bin
+ PATH=/nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin:/nix/store/1fn92b0783crypjcxvdv6ycmvi27by0j-binutils-2.40/bin:/nix/store/bblyj5b3ii8n6v4ra0nb37cmi3lf8rz9-coreutils-9.3/bin:/nix/store/7wfya2k95zib8jl0jk5hnbn856sqcgfk-gawk-5.2.2/bin:/nix/store/k93s5p63dsyyxih5lvl0mc6f0g7svbp7-libarchive-3.7.2/bin:/nix/store/sr6v1d6zyq1afwbbfryj2cyzh48p7g2v-pv-1.8.5/bin:/nix/store/325b9q4z86is6wzxqz59x3ik2ssfxa78-squashfs-4.6.1/bin:/run/wrappers/bin:/usr/bin:/usr/sbin:/nix/persistent/home/user/.local/share/opam/default/bin:/nix/store/kbcrs84s1x8yd5bp1nq6q6ihda8nd2lp-bash-interactive-5.2-p15/bin:/nix/store/ywwjpdyhar4f3vcqf4qk77vrbr3vj5wl-patchelf-0.15.0/bin:/nix/store/7wkshj58fcsl1f3zyi67qsxgl1p8nki1-gcc-wrapper-12.2.0/bin:/nix/store/dcd1zhv56rk0d2z7akzfjgzr076c4jl9-gcc-12.2.0/bin:/nix/store/lyvhsvwp2pzy74fkcn7qbs5vcgy5d7vl-glibc-2.37-8-bin/bin:/nix/store/ahkfdxq8mcpsb5kvdvgqr1wv8zjngbh4-coreutils-9.1/bin:/nix/store/rbwalnmk5a6nj9mbldxzmj11gvacbrsi-binutils-wrapper-2.40/bin:/nix/store/22p5nv7fbxhm06mfkwwnibv1nsz06x4b-binutils-2.40/bin:/nix/store/ahkfdxq8mcpsb5kvdvgqr1wv8zjngbh4-coreutils-9.1/bin:/nix/store/4qrbfa42xyicny7vlgbbqxz07kcsjbx2-findutils-4.9.0/bin:/nix/store/6bcqajyagcc4s3azx0zqnb3rqxd7gdnv-diffutils-3.9/bin:/nix/store/gy82r5cf12hgkmhzifsyx3fp6cnf6j2l-gnused-4.9/bin:/nix/store/zrls4w5lxynqakh1jlrp03kg4bxzp9yi-gnugrep-3.7/bin:/nix/store/s3yl3l8na93v53k2cfsyz0jrb50bnk8n-gawk-5.2.1/bin:/nix/store/czy796d2241296bdy45w87cmaiig50zr-gnutar-1.34/bin:/nix/store/hdbb5ayyrz1b5hicbsb4am8vin0xxxg6-gzip-1.12/bin:/nix/store/hd573q7097cxj5q29pnc3z0rvakz7ga3-bzip2-1.0.8-bin/bin:/nix/store/nnis9ph3wj866bbs0lalbf22i5bq8yry-gnumake-4.4.1/bin:/nix/store/rhvbjmcfnkg8i2dxpzr114cp1ws7f667-bash-5.2-p15/bin:/nix/store/x4ckkjsxfl4ihl82v0bzsyxs4ay2d5b5-patch-2.7.6/bin:/nix/store/8xjzmhw6hgqmynb5f1v7aw2lvafij405-xz-5.4.3-bin/bin:/nix/store/lcjsmsxqwd4vkq2wj5mmbyjzny3i6k49-file-5.44/bin:/nix/persistent/home/user/.local/share/opam/default/bin:/run/wrappers/bin:/nix/persistent/home/user/.local/bin:/nix/persistent/home/user/.nix-profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/etc/profiles/per-user/user/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/nix/store/1alqjnr40dsk7cl15l5sn5y2zdxidc1v-binutils-wrapper-2.40/bin:/nix/store/lvx8bvn5lc6aqjq2jalnq7xc9lhqbpzg-pciutils-3.10.0/bin:/nix/persistent/home/user/usr/bin
+ wrap
+ export APPIMAGE_SILENT_INSTALL=1
+ APPIMAGE_SILENT_INSTALL=1
+ '[' -n '' ']'
+ exec /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/AppRun
/usr/bin/appimage-exec.sh: line 89: /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/AppRun: No such file or directory

https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/build-support/trivial-builders/default.nix#L87 This is the code for appimage-run

@ncfavier @happysalada @hsjobeki @roberth

Metadata

my flake

[I] ~ [127]$ nix-shell -p nix-info --run "nix-info -m"                                                                                                                                                               
this path will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/nn818zlhq4hnx794c57adijwikdw6cqz-nix-info
copying path '/nix/store/nn818zlhq4hnx794c57adijwikdw6cqz-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.63, NixOS, 24.05 (Uakari), 24.05.20231124.fc23c76`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
eclairevoyant commented 9 months ago

questions are probably best asked on discourse.nixos.org, for future reference

leg7 commented 9 months ago

this is not a question it's a bug. I haven't been able to run appimages for like 6 months

eclairevoyant commented 9 months ago

as you said, it's likely related to misconfiguring impermanence, which is not a bug.

benaryorg commented 9 months ago

The first error seems to be this one:

mkdir: cannot create directory ‘/nix/persistent/home/user/.local/cache/appimage-run’: Read-only file system

The remainder are just results of that directory not existing further down the line.

What's confusing to me is that this points to ~/.local/cache instead of ~/.cache, which would be caused by a changed XDG_CACHE_HOME. This does indeed look like a misconfiguration of sorts. If the following command works as intended, it is likely that XDG_CACHE_HOME points at a wrong directory, however this pretty much rules out an issue with appimage-run.

env "XDG_CACHE_HOME=$(mktemp -dp /tmp)" appimage-run -d balenaEtcher-1.18.11-x64.AppImage

(note that running this will create a directory in /tmp, which should be possible even if your home directory is inaccessible in some locations, however it also means repeatedly running this command will create additional directories which you may want to clean up, if you're running on tmpfs it also requires some amount of memory to unpack the AppImage, you can point the XDG_CACHE_HOME to any directory that is actually writeable for your user)

For any further assistance the Discourse would be more appropriate. (checking for what's mounted in your home directory using findmnt --target ~/.local/cache will probably point you in the right direction)

leg7 commented 9 months ago

@benaryorg Yes I have set XDG_CACHE_HOME to a path in my users home directory. I use a window manager so I have to set this env var manually. I choose to set it to the default value suggested in the freedesktop standard.

$ echo $XDG_CACHE_HOME
/nix/persistent/home/user/.local/cache
$ tree -dL 1 ~/.local/cache
/nix/persistent/home/user/.local/cache
├── cabal
├── deno
├── dune
├── emacs
├── evolution
├── fontconfig
├── ghcide
├── ghcup
├── hie-bios
├── hyprland
├── jedi
├── lutris
├── matplotlib
├── mesa_shader_cache
├── mozilla
├── nix
├── nvidia
├── nvim
├── org-persist
├── R
├── thumbnails
├── vim
└── yt-dlp

24 directories

As you can see the cache directory doesn't pose any problems to any other programs except for app-image run.

I have also tried changing the permissions of the directory and the appimage directory but it didn't fix anything.

[I] ~/.local $ ls -lah                                                                                                                                                                                               
total 22K
drwx------  6 user users 3.4K Jun  7  2023 .
drwx------ 23 user users 8.0K Dec 12 18:44 ..
drwxr-xr-x 13 user users 3.4K Dec 10 19:25 bin
drwxrw-r-x 25 user users 3.4K Dec 10 11:28 cache
drwx------ 32 user users 3.4K Dec 12 18:44 share
drwx------  8 user users 3.4K Dec 12 18:46 state

By default if I try to run an appimage .../cache/appimage-run won't even be created.

[I] ~ [127]$ appimage-run -d balenaEtcher-1.18.11-x64.AppImage | wl-copy                                  
+ getopts x:w:dh option
+ shift 1
+ '[' -n '' ']'
++ realpath balenaEtcher-1.18.11-x64.AppImage
+ APPIMAGE=/nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ shift
+ '[' -n '' ']'
+ '[' -n true ']'
+ '[' -f /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage ']'
+ apprun
++ sha256sum /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk '{print $1}'
+ SHA256=f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ export APPDIR=/nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ APPDIR=/nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ '[' -x /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/squashfs-root ']'
+ '[' '!' -x /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50 ']'
++ dirname /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ mkdir -p /nix/persistent/home/user/.local/cache/appimage-run
mkdir: cannot create directory ‘/nix/persistent/home/user/.local/cache/appimage-run’: Read-only file system
+ unpack /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ local src=/nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ local out=/nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ local appimageSignature
++ LC_ALL=C
++ readelf -h /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk 'NR==2{print $10$11;}'
+ appimageSignature=4149
+ local appimageType
++ LC_ALL=C
++ readelf -h /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk 'NR==2{print $12;}'
+ appimageType=02
+ '[' 4149 '!=' 4149 ']'
+ case "$appimageType" in
++ LC_ALL=C
++ readelf -h /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk 'NR==13{e_shoff=$5} NR==18{e_shentsize=$5} NR==19{e_shnum=$5} END{print e_shoff+e_shentsize*e_shnum}'
+ offset=188392
++ basename /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ echo 'Uncompress balenaEtcher-1.18.11-x64.AppImage of type 02 @ offset 188392'
+ unsquashfs -q -d /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50 -o 188392 /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage

FATAL ERROR: dir_scan: failed to make directory /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50, because No such file or directory
+ chmod go-w /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
chmod: cannot access '/nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50': No such file or directory
++ basename /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ echo 'balenaEtcher-1.18.11-x64.AppImage is now installed in /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50'
+ export PATH=/nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin:/nix/store/1fn92b0783crypjcxvdv6ycmvi27by0j-binutils-2.40/bin:/nix/store/bblyj5b3ii8n6v4ra0nb37cmi3lf8rz9-coreutils-9.3/bin:/nix/store/7wfya2k95zib8jl0jk5hnbn856sqcgfk-gawk-5.2.2/bin:/nix/store/k93s5p63dsyyxih5lvl0mc6f0g7svbp7-libarchive-3.7.2/bin:/nix/store/sr6v1d6zyq1afwbbfryj2cyzh48p7g2v-pv-1.8.5/bin:/nix/store/325b9q4z86is6wzxqz59x3ik2ssfxa78-squashfs-4.6.1/bin:/run/wrappers/bin:/usr/bin:/usr/sbin:/nix/persistent/home/user/.local/share/opam/default/bin:/run/wrappers/bin:/nix/persistent/home/user/.local/bin:/nix/persistent/home/user/.nix-profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/etc/profiles/per-user/user/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/nix/store/1alqjnr40dsk7cl15l5sn5y2zdxidc1v-binutils-wrapper-2.40/bin:/nix/store/lvx8bvn5lc6aqjq2jalnq7xc9lhqbpzg-pciutils-3.10.0/bin:/nix/persistent/home/user/usr/bin
+ PATH=/nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin:/nix/store/1fn92b0783crypjcxvdv6ycmvi27by0j-binutils-2.40/bin:/nix/store/bblyj5b3ii8n6v4ra0nb37cmi3lf8rz9-coreutils-9.3/bin:/nix/store/7wfya2k95zib8jl0jk5hnbn856sqcgfk-gawk-5.2.2/bin:/nix/store/k93s5p63dsyyxih5lvl0mc6f0g7svbp7-libarchive-3.7.2/bin:/nix/store/sr6v1d6zyq1afwbbfryj2cyzh48p7g2v-pv-1.8.5/bin:/nix/store/325b9q4z86is6wzxqz59x3ik2ssfxa78-squashfs-4.6.1/bin:/run/wrappers/bin:/usr/bin:/usr/sbin:/nix/persistent/home/user/.local/share/opam/default/bin:/run/wrappers/bin:/nix/persistent/home/user/.local/bin:/nix/persistent/home/user/.nix-profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/etc/profiles/per-user/user/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/nix/store/1alqjnr40dsk7cl15l5sn5y2zdxidc1v-binutils-wrapper-2.40/bin:/nix/store/lvx8bvn5lc6aqjq2jalnq7xc9lhqbpzg-pciutils-3.10.0/bin:/nix/persistent/home/user/usr/bin
+ wrap
+ export APPIMAGE_SILENT_INSTALL=1
+ APPIMAGE_SILENT_INSTALL=1
+ '[' -n '' ']'
+ exec /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/AppRun
/usr/bin/appimage-exec.sh: line 89: /nix/persistent/home/user/.local/cache/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/AppRun: No such file or directory
[N] ~/.l/cache $ ls -lah                                                                                  
total 68G
drwxrw-r-x  25 user users 3.4K Dec 10 11:28 .
drwx------   6 user users 3.4K Jun  7  2023 ..
drwxr-xr-x   4 user users 3.4K Nov  5 16:42 cabal
drwxr-xr-x   5 user users 3.4K Sep 14 10:31 deno
drwxr-xr-x   2 user users 3.4K Oct 25 13:21 dune
drwxr-xr-x   3 user users 3.4K Sep 27 21:53 emacs
drwx------   8 user users 3.4K Oct 16 14:34 evolution
-rw-r--r--   1 user users  68G Dec 12 17:40 eww_1701e79c2d75f9a.log
drwxr-xr-x   2 user users  56K Dec 10 22:01 fontconfig
drwxr-xr-x   7 user users 4.0K Nov 26 20:34 ghcide
drwxr-xr-x   5 user users 3.4K Oct 31 14:56 ghcup
drwxr-xr-x   3 user users 3.4K Nov  5 16:48 hie-bios
drwxrwxrwx   2 user users 3.4K Dec 10 14:04 hyprland
drwxr-xr-x   3 user users 3.4K Oct  3 14:28 jedi
drwxr-xr-x   7 user users 3.4K Nov  3 22:24 lutris
drwxr-xr-x   2 user users 3.4K Oct 11 13:01 matplotlib
drwxr-xr-x 258 user users 8.0K Jul 11 20:04 mesa_shader_cache
drwx------   3 user users 3.4K Jun  7  2023 mozilla
drwxr-xr-x   4 root root  3.4K Sep 17 21:06 nix
drwx------   3 user users 3.4K Jul 10 17:52 nvidia
drwxr-xr-x   4 user users 3.4K Oct 22 21:12 nvim
drwxr-xr-x   4 user users 3.4K Dec 12 14:05 org-persist
drwxr-xr-x   4 user users 3.4K Sep 26 15:39 R
drwx------   4 user users 3.4K Jun 20 11:04 thumbnails
drwx------   5 user users 3.4K Nov 22 19:38 vim
-rw-r--r--   1 user users   27 Dec 11 20:47 wofi-dmenu
-rw-r--r--   1 user users  766 Dec 12 18:27 wofi-drun
drwxr-xr-x   3 user users 3.4K Jun 11  2023 yt-dlp

yes I just noticed noticed I have a 68GB logfile while writing this what the fuckkkk https://github.com/elkowar/eww/issues/1000

Anyways using the command you suggested fixes that error but I still don't understand why it's happening in the first place.

[user@eleum:~]$ env "XDG_CACHE_HOME=$(mktemp -dp /tmp)" appimage-run -d balenaEtcher-1.18.11-x64.AppImage
+ getopts x:w:dh option
+ shift 1
+ '[' -n '' ']'
++ realpath balenaEtcher-1.18.11-x64.AppImage
+ APPIMAGE=/nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ shift
+ '[' -n '' ']'
+ '[' -n true ']'
+ '[' -f /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage ']'
+ apprun
++ sha256sum /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk '{print $1}'
+ SHA256=f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ export APPDIR=/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ APPDIR=/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ '[' -x /tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/squashfs-root ']'
+ '[' '!' -x /tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50 ']'
++ dirname /tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ mkdir -p /tmp/tmp.LU9A1kyVJU/appimage-run
+ unpack /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage /tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ local src=/nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ local out=/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ local appimageSignature
++ LC_ALL=C
++ readelf -h /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk 'NR==2{print $10$11;}'
+ appimageSignature=4149
+ local appimageType
++ LC_ALL=C
++ readelf -h /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk 'NR==2{print $12;}'
+ appimageType=02
+ '[' 4149 '!=' 4149 ']'
+ case "$appimageType" in
++ LC_ALL=C
++ readelf -h /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
++ awk 'NR==13{e_shoff=$5} NR==18{e_shentsize=$5} NR==19{e_shnum=$5} END{print e_shoff+e_shentsize*e_shnum}'
+ offset=188392
++ basename /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ echo 'Uncompress balenaEtcher-1.18.11-x64.AppImage of type 02 @ offset 188392'
Uncompress balenaEtcher-1.18.11-x64.AppImage of type 02 @ offset 188392
+ unsquashfs -q -d /tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50 -o 188392 /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
[=======================================================================================|] 2041/2041 100%
+ chmod go-w /tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
++ basename /nix/persistent/home/user/balenaEtcher-1.18.11-x64.AppImage
+ echo 'balenaEtcher-1.18.11-x64.AppImage is now installed in /tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50'
balenaEtcher-1.18.11-x64.AppImage is now installed in /tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50
+ export PATH=/nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin:/nix/store/1fn92b0783crypjcxvdv6ycmvi27by0j-binutils-2.40/bin:/nix/store/bblyj5b3ii8n6v4ra0nb37cmi3lf8rz9-coreutils-9.3/bin:/nix/store/7wfya2k95zib8jl0jk5hnbn856sqcgfk-gawk-5.2.2/bin:/nix/store/k93s5p63dsyyxih5lvl0mc6f0g7svbp7-libarchive-3.7.2/bin:/nix/store/sr6v1d6zyq1afwbbfryj2cyzh48p7g2v-pv-1.8.5/bin:/nix/store/325b9q4z86is6wzxqz59x3ik2ssfxa78-squashfs-4.6.1/bin:/run/wrappers/bin:/usr/bin:/usr/sbin:/nix/persistent/home/user/.local/share/opam/default/bin:/run/wrappers/bin:/nix/persistent/home/user/.local/bin:/nix/persistent/home/user/.nix-profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/etc/profiles/per-user/user/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/nix/store/1alqjnr40dsk7cl15l5sn5y2zdxidc1v-binutils-wrapper-2.40/bin:/nix/store/lvx8bvn5lc6aqjq2jalnq7xc9lhqbpzg-pciutils-3.10.0/bin:/nix/persistent/home/user/usr/bin
+ PATH=/nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin:/nix/store/1fn92b0783crypjcxvdv6ycmvi27by0j-binutils-2.40/bin:/nix/store/bblyj5b3ii8n6v4ra0nb37cmi3lf8rz9-coreutils-9.3/bin:/nix/store/7wfya2k95zib8jl0jk5hnbn856sqcgfk-gawk-5.2.2/bin:/nix/store/k93s5p63dsyyxih5lvl0mc6f0g7svbp7-libarchive-3.7.2/bin:/nix/store/sr6v1d6zyq1afwbbfryj2cyzh48p7g2v-pv-1.8.5/bin:/nix/store/325b9q4z86is6wzxqz59x3ik2ssfxa78-squashfs-4.6.1/bin:/run/wrappers/bin:/usr/bin:/usr/sbin:/nix/persistent/home/user/.local/share/opam/default/bin:/run/wrappers/bin:/nix/persistent/home/user/.local/bin:/nix/persistent/home/user/.nix-profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/nix/persistent/home/user/.local/state/nix/profile/bin:/etc/profiles/per-user/user/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/nix/store/1alqjnr40dsk7cl15l5sn5y2zdxidc1v-binutils-wrapper-2.40/bin:/nix/store/lvx8bvn5lc6aqjq2jalnq7xc9lhqbpzg-pciutils-3.10.0/bin:/nix/persistent/home/user/usr/bin
+ wrap
+ export APPIMAGE_SILENT_INSTALL=1
+ APPIMAGE_SILENT_INSTALL=1
+ '[' -n '' ']'
+ exec /tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/AppRun
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Failed to get 'userData' path
    at Object.<anonymous> (/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/resources/app/generated/etcher.js:1:242166)
    at __webpack_require__ (/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/resources/app/generated/etcher.js:3:917423)
    at /tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/resources/app/generated/etcher.js:3:918774
    at Object.<anonymous> (/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/resources/app/generated/etcher.js:3:918820)
    at Module._compile (node:internal/modules/cjs/loader:1118:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at Object.<anonymous> (node:electron/js2c/browser_init:185:3104)
(node:134416) UnhandledPromiseRejectionWarning: Error: Failed to get 'userData' path
    at getConfigPath (/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/resources/app/generated/etcher.js:1:101300)
    at readAll (/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/resources/app/generated/etcher.js:1:101624)
    at load (/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/resources/app/generated/etcher.js:1:102076)
    at Object.<anonymous> (/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/resources/app/generated/etcher.js:1:102147)
    at __webpack_require__ (/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/resources/app/generated/etcher.js:3:917423)
    at /tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/resources/app/generated/etcher.js:3:918774
    at Object.<anonymous> (/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/resources/app/generated/etcher.js:3:918820)
    at Module._compile (node:internal/modules/cjs/loader:1118:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
(Use `balena-etcher.bin --trace-warnings ...` to show where the warning was created)
(node:134416) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
/tmp/tmp.LU9A1kyVJU/appimage-run/f87bbbd1439c98b5f874f39810103669d05d5ff0bc472a7fd7b6ef8be8d47d50/balena-etcher: line 10: 134416 Trace/breakpoint trap   (core dumped) "${script_dir}"/balena-etcher.bin "$@"
benaryorg commented 9 months ago

By default if I try to run an appimage .../cache/appimage-run won't even be created. I have also tried changing the permissions of the directory and the appimage directory but it didn't fix anything.

Correct, the creation of the directory fails with "Read-only file system", which means this is unrelated to permissions, and instead is a filesystem mounted read-only in that space, permissions won't change the outcome here.

Anyways using the command you suggested fixes that error but I still don't understand why it's happening in the first place. As you can see the cache directory doesn't pose any problems to any other programs except for app-image run.

The link to the appimage-run source code you sent in the opening post is only half of the magic used by the tool. The more relevant part is the chrootenv script which is used to isolate the appimage process into a different mount namespace. The entire appimage-run code you linked earlier does therefore run in a different mount namespace with a separate directory structure and some bind mounts. For instance, the following list of directories is not mounted at all in the namespace:

https://github.com/NixOS/nixpkgs/blob/1a5412e14030d2a00281021d5f8ef05b31027912/pkgs/build-support/build-fhsenv-chroot/chrootenv/src/chrootenv.c#L21

The difficult part here is to determine what causes the filesystem to be read-only in the created mount namespace. If you check the content of the appimage-run wrapper (cat $(command -v appimage-run)) you will find the path to the chrootenv binary. With this binary you can reproduce the environment in which the error occurs, for instance by running this command (replace the path to your chrootenv according to the content of your appimage-run wrapper):

/nix/store/nqkfvyxi0hhaf7k251lxvz50xx41934r-chrootenv/bin/chrootenv $SHELL

This will allow you to enter an interactive shell in that environment to determine the root cause. Despite some genuine effort I have not been able to reproduce any issues, so what that may help pin down what exactly the problem is would be to compare the output of the following command within the chrootenv shell and outside of it:

findmnt --output TARGET,FSTYPE,OPT-FIELDS,OPTIONS -N $$

Any difference in mounted filesystems, especially missing filesystems or diverging options would no doubt be relevant.

Furthermore double check whether any of the involved paths have any symlinks in them as these may not necessarily resolve correctly (e.g. if a symlink were to point to /opt or /bin which is not present in the chrootenv environment this would fail), using realpath for instance.


As a side-note:

Yes I have set XDG_CACHE_HOME to a path in my users home directory. […] I choose to set it to the default value suggested in the freedesktop standard.

FYI: The XDG Base Directory Specification refers to $HOME/.config, not $HOME/.local/config.

leg7 commented 9 months ago

@benaryorg I've checked to contents of appimage-run and could not find any instances of chrootenv. Probably because of some system settings I have enabled. Here's the output.

[I] ~ $ cat $(command -v appimage-run)

#!/nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin/bash
ignored=(/nix /dev /proc /etc)
ro_mounts=()
symlinks=()
etc_ignored=()
for i in /nix/store/bcyir8pj2bddq74aijmqq45xgbsr28q0-appimage-run-fhs/*; do
  path="/${i##*/}"
  if [[ $path == '/etc' ]]; then
    :
  elif [[ -L $i ]]; then
    symlinks+=(--symlink "$(/nix/store/bblyj5b3ii8n6v4ra0nb37cmi3lf8rz9-coreutils-9.3/bin/readlink "$i")" "$path")
    ignored+=("$path")
  else
    ro_mounts+=(--ro-bind "$i" "$path")
    ignored+=("$path")
  fi
done

if [[ -d /nix/store/bcyir8pj2bddq74aijmqq45xgbsr28q0-appimage-run-fhs/etc ]]; then
  for i in /nix/store/bcyir8pj2bddq74aijmqq45xgbsr28q0-appimage-run-fhs/etc/*; do
    path="/${i##*/}"
    # NOTE: we're binding /etc/fonts and /etc/ssl/certs from the host so we
    # don't want to override it with a path from the FHS environment.
    if [[ $path == '/fonts' || $path == '/ssl' ]]; then
      continue
    fi
    ro_mounts+=(--ro-bind "$i" "/etc$path")
    etc_ignored+=("/etc$path")
  done
fi

for i in '/etc/static' '/etc/nix' '/etc/shells' '/etc/bashrc' '/etc/zshenv' '/etc/zshrc' '/etc/zinputrc' '/etc/zprofile' '/etc/passwd' '/etc/group' '/etc/shadow' '/etc/hosts' '/etc/resolv.conf' '/etc/nsswitch.conf' '/etc/profiles' '/etc/login.defs' '/etc/sudoers' '/etc/sudoers.d' '/etc/localtime' '/etc/zoneinfo' '/etc/machine-id' '/etc/os-release' '/etc/pam.d' '/etc/fonts' '/etc/alsa' '/etc/asound.conf' '/etc/ssl/certs' '/etc/ca-certificates' '/etc/pki'; do
  if [[ "${etc_ignored[@]}" =~ "$i" ]]; then
    continue
  fi
  if [[ -L $i ]]; then
    symlinks+=(--symlink "$(/nix/store/bblyj5b3ii8n6v4ra0nb37cmi3lf8rz9-coreutils-9.3/bin/readlink "$i")" "$i")
  else
    ro_mounts+=(--ro-bind-try "$i" "$i")
  fi
done

declare -a auto_mounts
# loop through all directories in the root
for dir in /*; do
  # if it is a directory and it is not ignored
  if [[ -d "$dir" ]] && [[ ! "${ignored[@]}" =~ "$dir" ]]; then
    # add it to the mount list
    auto_mounts+=(--bind "$dir" "$dir")
  fi
done

declare -a x11_args
# Always mount a tmpfs on /tmp/.X11-unix
# Rationale: https://github.com/flatpak/flatpak/blob/be2de97e862e5ca223da40a895e54e7bf24dbfb9/common/flatpak-run.c#L277
x11_args+=(--tmpfs /tmp/.X11-unix)

# Try to guess X socket path. This doesn't cover _everything_, but it covers some things.
if [[ "$DISPLAY" == :* ]]; then
  display_nr=${DISPLAY#?}
  local_socket=/tmp/.X11-unix/X$display_nr
  x11_args+=(--ro-bind-try "$local_socket" "$local_socket")
fi

cmd=(
  /nix/store/xkl370pyh843b6ymd81622cs38js2y1y-bubblewrap-0.8.0/bin/bwrap
  --dev-bind /dev /dev
  --proc /proc
  --chdir "$(pwd)"

  --die-with-parent
  --ro-bind /nix /nix
  # Our glibc will look for the cache in its own path in `/nix/store`.
  # As such, we need a cache to exist there, because pressure-vessel
  # depends on the existence of an ld cache. However, adding one
  # globally proved to be a bad idea (see #100655), the solution we
  # settled on being mounting one via bwrap.
  # Also, the cache needs to go to both 32 and 64 bit glibcs, for games
  # of both architectures to work.
  --tmpfs /nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/etc \
  --symlink /etc/ld.so.conf /nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/etc/ld.so.conf \
  --symlink /etc/ld.so.cache /nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/etc/ld.so.cache \
  --ro-bind /nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/etc/rpc /nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/etc/rpc \
  --remount-ro /nix/store/qn3ggz5sf3hkjs2c797xf7nan3amdxmp-glibc-2.38-27/etc \
  --tmpfs /nix/store/nmimzmfi0ccr9cha4vgl0mgsbdzzibhj-glibc-2.38-27/etc \
  --symlink /etc/ld.so.conf /nix/store/nmimzmfi0ccr9cha4vgl0mgsbdzzibhj-glibc-2.38-27/etc/ld.so.conf \
  --symlink /etc/ld.so.cache /nix/store/nmimzmfi0ccr9cha4vgl0mgsbdzzibhj-glibc-2.38-27/etc/ld.so.cache \
  --ro-bind /nix/store/nmimzmfi0ccr9cha4vgl0mgsbdzzibhj-glibc-2.38-27/etc/rpc /nix/store/nmimzmfi0ccr9cha4vgl0mgsbdzzibhj-glibc-2.38-27/etc/rpc \
  --remount-ro /nix/store/nmimzmfi0ccr9cha4vgl0mgsbdzzibhj-glibc-2.38-27/etc \
  "${ro_mounts[@]}"
  "${symlinks[@]}"
  "${auto_mounts[@]}"
  "${x11_args[@]}"

  /nix/store/i94wwm46jw9xhwbjmvnq0zd9n18a2if6-appimage-run-init "$@"
)
exec "${cmd[@]}"

I'm 99% sure this line is the culprit near the end of the program --ro-bind /nix /nix. My system uses impermanence so I have it setup to forget everything except for /nix on every poweroff.

[N] ~ $ tree -L 1 /nix                                                                                    
/nix
├── persistent
├── store
└── var

4 directories, 0 files

Naturally then I save the files I want to persist between reboots in /nix/persistent and let impermanence bind mount my state in /nix/persistent to the right places as you can see in my flake here.

I think to fix this issue I would have to replace --ro-bind /nix /nix by something like --ro-bind /nix/store /nix/store; --ro-bind /nix/var /nix/var. I'm not sure how to test these changes on my system though so If you could point me to ressources explaining that or tell me what to do that would be greatly appreciated.

benaryorg commented 9 months ago

Oh my goodness, I humbly apologize, the one machine I used to test this has been stuck on using nix-env installed packages vs. the flakes everywhere else, which left appimage-run in a pre- 1baab4e14a6c9d5fd0f3e6af144aeeb61e911110.

Okay, now that I've caught up with the times, and bubblewrap seems to be the way to go, I agree. Bind-mounting the entire /nix area as read-only seems problematic, and at least one other place where the nix-store is bind mounted read-only, the nixos container infrastructure, does indeed make more specific bind-mounts:

https://github.com/NixOS/nixpkgs/blob/9b9778125203413c8c30023be36ff7b8d3db9474/nixos/modules/virtualisation/nixos-containers.nix#L158-L162)

I think changing the originating code to use a similarly specific bind-mount is reasonable.

leg7 commented 9 months ago

@benaryorg Do you know how I could change this code on my machine to test if this change would fix the issue?

Edit: I mean locally. I could always fork nixpkgs and change the code in my repo and use that is my input.

benaryorg commented 9 months ago

So for one, if you really just wanna get things working for now, you could revert back to the previous chrootenv based approach by specifying the appimage-run package (e.g. in your environment.sysemPackages or similar) like this:

with pkgs; appimage-run.override { buildFHSEnv = buildFHSEnvChroot; }

This would use the script that I erroneously referred to previously which shouldn't suffer from that problem.

When it comes to actually making the bubblewrap version do that I can't seem to find an easy way that doesn't result in copy&pasting half the code though, since the relevant parts seem to be part of a let binding, which can't be easily overriden to my knowledge (i.e. changing the code itself, not its parameters). However on second glance the more restrictive mounting wouldn't even solve your problem, as bubblewrap in this case would just not mount the directory at all then, neither read-write nor read-only, leaving you with a technically writable filesystem in its place but not one that actually uses your persistent directories either.

The path of /nix is [explicitly]https://github.com/NixOS/nixpkgs/blob/9b9778125203413c8c30023be36ff7b8d3db9474/pkgs/build-support/build-fhsenv-bubblewrap/default.nix#L119) excluded from the auto-mounting which leads me to believe that the /nix directory is subject to assumptions which stretch throughout nixpkgs; as far as I see it you shouldn't put your own data in /nix, as the structure of /nix is part of how NixOS handles things internally. The impermanence flake which you are using does not use a subdirectory of /nix in its documentation either, and using a path like /persistence or anything else that is outside the ignored directories (or special directories like proc, sys, etc.) would work just fine. If you are really set on using that specific directory your best bet would likely be to somehow overwrite the extraBwrapArgs using an overlay like this:

# use via `pkgs.extend` or add to `overlays`
(final: prev: { buildFHSEnvBubblewrap = (args@{ extraBwrapArgs ? [], ... }: prev.buildFHSEnvBubblewrap (args // { extraBwrapArgs = extraBwrapArgs ++ [ "--bind /nix/persistent /nix/persistent" ]; })); })

TL;DR: I think the entire nixpkgs structure and the way that the /nix directory is laid out and used assume that you do not store any custom data in there and the easiest solution would be to store your persistent data quite literally anywhere else.

leg7 commented 2 days ago

I solved this by not having my persistent data under /nix