Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running on Android (Termux) #424

Open
luisdavim opened this issue Apr 13, 2024 · 2 comments
Open

Error running on Android (Termux) #424

luisdavim opened this issue Apr 13, 2024 · 2 comments

Comments

@luisdavim
Copy link

luisdavim commented Apr 13, 2024

I'm getting the folloing error:

$ udocker run quay.io/giantswarm/debug
Info: downloading layer sha256:670ede3d39ae57d0ad8cfd9c6d21e31eb2e394def3f7bb5b5a3a00d0cfa1e394
Info: downloading layer sha256:750ce8d28ced8a50b02aa7c1735bb3973065495b9eefbd3f18a5f1c0b50516ab
Info: downloading layer sha256:0d00e96b2dbce65991da53bc5fe08b761f9d767c89e6e1c36ca0b7bcf6c5bd49
Info: downloading layer sha256:7597eaba0060104f2bd4f3c46f0050fcf6df83066870767af41c2d7696bb33b2
Error: while extracting image layer
Error: creating container: 76367a60-0d79-3f79-a0cb-bee9025af8d4

 ******************************************************************************
 *                                                                            *
 *               STARTING 76367a60-0d79-3f79-a0cb-bee9025af8d4                *
 *                                                                            *
 ******************************************************************************
 executing: sh
proot error: 'qemu-x86_64' not found (root = (null), cwd = /data/data/com.termux/files/home, $PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
fatal error: see `proot-arm64-4_8_0 --help`.
$ type qemu-x86_64
qemu-x86_64 is /data/data/com.termux/files/usr/bin/qemu-x86_64

though I do have booth qemu-system and qemu-user installed.

I've tryed setting root_path but that doesn't seem to have any effect:

$ cat ~/.udocker/udocker.conf
[DEFAULT]
root_path = /data/data/com.termux/files/home/.theme.sh/bin:/data/data/com.termux/files/home/.local/bin:/data/data/com.termux/files/home/.kitty-tmux:/data/data/com.termux/files/home/.cargo/bin:/data/data/com.termux/files/home/.krew/bin:/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/home/go/bin
@George-Seven
Copy link

George-Seven commented Apr 19, 2024

Error: while extracting image layer

Apply this fix for udocker to extract images properly in Android environment -

https://github.com/George-Seven/gpt4free-Termux/blob/20d4dca3b28ee7495e3bcfc00c7d94aafbfe7efd/g4f.sh#L65-L83

# Fix errors when extracting hardlinks from Docker images
# https://github.com/indigo-dc/udocker/issues/388#issuecomment-1527277800
UDOCKER_PATCH='
--- udocker/container/structure.py
+++ udocker.mod/container/structure.py
@@ -281,7 +281,7 @@
             if Msg.level >= Msg.VER:
                 verbose = '\'v'\''
                 Msg().out("Info: extracting:", tarf, l=Msg.INF)
-            cmd = ["tar", "-C", destdir, "-x" + verbose,
+            cmd = ["proot", "--link2symlink", "tar", "-C", destdir, "-x" + verbose,
                    "--one-file-system", "--no-same-owner", "--overwrite",
                    "--exclude=dev/*", "--exclude=etc/udev/devices/*",
                    "--no-same-permissions", r"--exclude=.wh.*",
'

TMP_PATCH_FILE="$(mktemp)"
patch -p0 --no-backup-if-mismatch -r "${TMP_PATCH_FILE}" -d "$(python -c "import sysconfig; print(sysconfig.get_path('platlib'))" 2>/dev/null || echo "${PREFIX}/lib/python3.11/site-packages")" 2>/dev/null >/dev/null <<< "${UDOCKER_PATCH}" || true
rm -rf "${TMP_PATCH_FILE}"

'qemu-x86_64' not found

Apply this fix for udocker so that it finds qemu -

# Fix qemu not found errors that occurs when running non-native platform containers
UDOCKER_PATCH='
--- udocker/engine/base.py
+++ udocker.mod/engine/base.py
@@ -690,4 +690,4 @@
         if not qemu_path:
             Msg().err("Warning: qemu required but not available", l=Msg.WAR)
             return ""
-        return qemu_path if return_path else qemu_filename
+        return qemu_path if return_path else qemu_path
'

TMP_PATCH_FILE="$(mktemp)"
patch -p0 --no-backup-if-mismatch -r "${TMP_PATCH_FILE}" -d "$(python -c "import sysconfig; print(sysconfig.get_path('platlib'))" 2>/dev/null || echo "${PREFIX}/lib/python3.11/site-packages")" 2>/dev/null >/dev/null <<< "${UDOCKER_PATCH}" || true
rm -rf "${TMP_PATCH_FILE}"

https://github.com/George-Seven/gpt4free-Termux/blob/20d4dca3b28ee7495e3bcfc00c7d94aafbfe7efd/g4f.sh#L89-L104


fatal error: see proot-arm64-4_8_0

You should use proot provided by Termux.The one provided by udocker doesn't work properly -

https://github.com/George-Seven/gpt4free-Termux/blob/20d4dca3b28ee7495e3bcfc00c7d94aafbfe7efd/g4f.sh#L449-L458

# Force use Termux provided proot
mkdir -p "${HOME}/.udocker/lib"
cat <<'EOF' > "${HOME}/.udocker/udocker.conf"
[DEFAULT]
use_proot_executable = /data/data/com.termux/files/usr/bin/proot
proot_link2symlink = True
verbose_level = 3
EOF
echo "2.9.9" > "${HOME}/.udocker/lib/VERSION"
# Create dummy VERSION to suppress redundant download of Android-incompatible udockertools
# https://github.com/indigo-dc/udocker/issues/376#issuecomment-1300626183

@luisdavim
Copy link
Author

luisdavim commented Apr 19, 2024

Thanks, I'll give this a try.
Is there a way udocker could detect that it's in Termux and use different paths?

Maybe by checking if ${PREFIX} is set and/or checking ${OSTYPE}, or uname -o

$ echo $OSTYPE
linux-android

$ uname -o
Android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants