Skip to content

Navigation Menu

Sign in
Sign up

AppImage breaks nested launching from Python #1435

Open

Description

The problem demonstrated on an extracted AppImage:

[0] % ./AppRun 
Traceback (most recent call last):
 File "/home/c0rn3j/Downloads/appimage-trixie-amd64/squashfs-root/usr/bin/scc", line 8, in <module>
 sys.exit(main())
 ~~~~^^
 File "/home/c0rn3j/Downloads/appimage-trixie-amd64/squashfs-root/usr/lib/python3.13/site-packages/scc/scripts.py", line 412, in main
 sys.exit(command(sys.argv[0], sys.argv[2:]))
 ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/c0rn3j/Downloads/appimage-trixie-amd64/squashfs-root/usr/lib/python3.13/site-packages/scc/scripts.py", line 47, in cmd_gui
 return run_binary("sc-controller", argv)
 File "/home/c0rn3j/Downloads/appimage-trixie-amd64/squashfs-root/usr/lib/python3.13/site-packages/scc/scripts.py", line 30, in run_binary
 child = subprocess.Popen([binary] + argv)
 File "/home/c0rn3j/Downloads/appimage-trixie-amd64/squashfs-root/usr/lib/python3.13/subprocess.py", line 1039, in __init__
 self._execute_child(args, executable, preexec_fn, close_fds,
 ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 pass_fds, cwd, env,
 ^^^^^^^^^^^^^^^^^^^
 ...<5 lines>...
 gid, gids, uid, umask,
 ^^^^^^^^^^^^^^^^^^^^^^
 start_new_session, process_group)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/c0rn3j/Downloads/appimage-trixie-amd64/squashfs-root/usr/lib/python3.13/subprocess.py", line 1857, in _execute_child
 self._posix_spawn(args, executable, env, restore_signals, close_fds,
 ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 p2cread, p2cwrite,
 ^^^^^^^^^^^^^^^^^^
 c2pread, c2pwrite,
 ^^^^^^^^^^^^^^^^^^
 errread, errwrite)
 ^^^^^^^^^^^^^^^^^^
 File "/home/c0rn3j/Downloads/appimage-trixie-amd64/squashfs-root/usr/lib/python3.13/subprocess.py", line 1801, in _posix_spawn
 self.pid = os.posix_spawn(executable, args, env, **kwargs)
 ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/c0rn3j/Downloads/appimage-trixie-amd64/squashfs-root/usr/bin/sc-controller'

Now, changing the usr/bin/env python in sc-controller to /usr/bin/env python solves this, because it no longer tries to load the AppImage-castrated env binary that relies on lib64/ld-linux-x86-64.so.2 to exist, but we're not in runtime/compat where it resides.

So we get this wonderful error when launching directly, and the same issue will break the binary when launched through Python:

./env 
zsh: no such file or directory: ./env

Now, the scripts.py is launching it this way: https://github.com/C0rn3j/sc-controller/blob/5a8e3025f75c214a54db05d438e2bbab015cf057/scc/scripts.py#L28

This works on Python 3.12 and earlier, but not Python 3.13, since that now uses posix_spawn() by default in this situation - https://docs.python.org/3/whatsnew/3.13.html#subprocess

A workaround is to preface subprocess.Popen calls with:

subprocess._USE_POSIX_SPAWN = False

Or replacing the shebang with the host's /usr/bin/env, if env is all you use in your shebangs.

What am I supposed to do here?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      AltStyle によって変換されたページ (->オリジナル) /