I do some development in Termux on my Android phon...
# general
p
I do some development in Termux on my Android phone. Termux only provides one version of python at a time (3.11 for now). So I figured I'd experiment with running the scie-pants binary so it can pull in its own python. So far, it hasn't worked. 🧵
I get this if I try to run in the pants repo:
Copy code
~/git/pants $ pants --version
Error: Failed to exec process.

Caused by:
    ENOENT: No such file or directory
Edit: I found the source of this error and filed https://github.com/pantsbuild/scie-pants/issues/148
I get this in the st2 repo:
Copy code
~/git/st2 $ pants --version
Downloading <https://github.com/indygreg/python-build-standalone/releases/download/20221106/cpython-3.9.15+20221106-aarch64-unknown-linux-gnu-install_only.tar.gz|https://github.com/indygreg/python-build-standalone/releases/download/20221106/cpython-3.9.15+20221106-aarch64-unknown-linux-gnu-install_only.tar.gz>...
[snip duplicate Downloading messages]
Downloading <https://github.com/indygreg/python-build-standalone/releases/download/20221106/cpython-3.9.15+20221106-aarch64-unknown-linux-gnu-install_only.tar.gz|https://github.com/indygreg/python-build-standalone/releases/download/20221106/cpython-3.9.15+20221106-aarch64-unknown-linux-gnu-install_only.tar.gz>...
Failed to source file cpython-3.9.15+20221106-aarch64-unknown-linux-gnu-install_only.tar.gz: Failed to fetch <https://github.com/indygreg/python-build-standalone/releases/download/20221106/cpython-3.9.15+20221106-aarch64-unknown-linux-gnu-install_only.tar.gz|https://github.com/indygreg/python-build-standalone/releases/download/20221106/cpython-3.9.15+20221106-aarch64-unknown-linux-gnu-install_only.tar.gz>: [6] Couldn't resolve host name (Could not resolve host: <http://github.com|github.com>)
Error: Isolates your Pants from the elements.

Please select from the following boot commands:
 
[snip boot commands]

You can select a boot command by passing it as the 1st argument or else by setting the SCIE_BOOT environment variable.

ERROR: Failed to establish atomic directory /data/data/com.termux/files/home/.cache/nce/8bd259181e05963da9f88937eb792e9f1b3dd0205c500ad1e0c86685e31bdb1d/locks/configure-521fac2917ca5b3aa1b53bfcfe140da3fd6afdea57eb50986d03bb0ab54826b3. Population of work directory failed: Failed to establish atomic directory /data/data/com.termux/files/home/.cache/nce/52a8c0a67fb919f80962d992da1bddb511cdf92faf382701ce7673e10a8ff98f/cpython-3.9.15+20221106-aarch64-unknown-linux-gnu-install_only.tar.gz. Population of work directory failed: The tar.gz destination /data/data/com.termux/files/home/.cache/nce/52a8c0a67fb919f80962d992da1bddb511cdf92faf382701ce7673e10a8ff98f/cpython-3.9.15+20221106-aarch64-unknown-linux-gnu-install_only.tar.gz of size 0 had unexpected hash: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
However, I can use wget or curl to download that path without issue.
f
stackoverflow questions suggest that this can be Android permissions needed by Termux
are curl/wget configured in any special way in termux?
p
I've already set up Termux permissions and allowed all I can. Curl and wget come from the Termux package repo. I'm not sure how they might be patched.
Also, scie-pants is able to write files and directories, because there are things in the ~/.cache/nce So something to do with network access
f
Do your Android system logs have anything relevant in them?
adb logcat
And you can always try running scie-pants under
strace
and see if any syscall errors show up.
👀 1
(I have no ideas; just suggesting some potential avenues for debugging this.)
p
Cool. I didn't know about
logcat:
Copy code
04-02 15:15:56.393  4722  4722 W bash    : type=1400 audit(0.0:186223): avc: granted { execute } for name="pants" dev="dm-41" ino=1201376 scontext=u:r:untrusted_app_27:s0:c70,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c70,c256,c512,c768 tclass=file app=com.termux.api
04-02 15:15:56.397  4722  4722 W bash    : type=1400 audit(0.0:186224): avc: granted { execute } for name="pants" dev="dm-41" ino=1201376 scontext=u:r:untrusted_app_27:s0:c70,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c70,c256,c512,c768 tclass=file app=com.termux.api
04-02 15:15:56.397  4722  4722 W bash    : type=1400 audit(0.0:186225): avc: granted { execute_no_trans } for path="/data/data/com.termux/files/home/.local/bin/pants" dev="dm-41" ino=1201376 scontext=u:r:untrusted_app_27:s0:c70,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c70,c256,c512,c768 tclass=file app=com.termux.api
04-02 15:15:56.400  4722  4722 W pants   : type=1400 audit(0.0:186226): avc: granted { execute } for path="/data/data/com.termux/files/home/.local/bin/pants" dev="dm-41" ino=1201376 scontext=u:r:untrusted_app_27:s0:c70,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c70,c256,c512,c768 tclass=file app=com.termux.api
04-02 15:15:56.410  4722  4722 W pants   : type=1400 audit(0.0:186227): avc: granted { execute } for name="scie-pants.bin" dev="dm-41" ino=1399128 scontext=u:r:untrusted_app_27:s0:c70,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c70,c256,c512,c768 tclass=file app=com.termux.api
That log only shows
granted
and that's all logcat shows when running scie-pants. Hmm
f
What happens when you run
curl
or
wget
?
(in the logs)
p
Wget showed almost the exact same logs, but for that app.
f
What does it say for
scontext
?
Curious if it says
untrusted_app
like it did for pants as well for
wget
or something else.
p
Example:
Copy code
04-02 15:31:22.413 10784 10784 W wget    : type=1400 audit(0.0:188710): avc: granted { execute } for path="/data/data/com.termux/files/usr/bin/wget" dev="dm-41" ino=1032404 scontext=u:r:untrusted_app_27:s0:c70,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c70,c256,c512,c768 tclass=file app=com.termux.api
f
ah so still
untrusted_app_27
p
Yeah. I'm guessing everything is untrusted except for system provided libs/apps
I think it is similar to this issue: https://github.com/pantsbuild/scie-pants/issues/148 Looking at the strace, it looked all over for ssl/tls stuff. It also tried to access /etc/resolve.conf
Copy code
14233 openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
So, it doesn't know how to look up dns settings. It was able to find the SSL files after looking all over the place. Looking at the strace for wget, it looks under the prefix to find the file:
/data/data/com.termux/files/usr/etc/resolv.conf
Copy code
19411 openat(AT_FDCWD, "/data/data/com.termux/files/usr/etc/resolv.conf", O_RDONLY) = 12
f
From looking at some of the termux package builds in https://github.com/termux/termux-packages, the termux builds patch file locations for stuff like that.
p
Yeah. So, how can we have a portable version that works both in a prefix and not? Hmm.
f
running Pants on Android seems like a very niche use case. maybe just define a termux package build for the scie-pants launcher?
(and then patch whatever needs to be patched as part of that build process)
were you using a binary from the scie-pants project or one that you build directly in termux?
building it for the termux environment would use a patched libc I assume so resolv.conf location would already be patched
p
The one from scie-pants
f
yeah so rebuilding the scie-pants binary for the termux environment is probably the way to go then
using the termux-packages stuff
p
Bummer. I'll have to try building it at some point. I'm afraid that might mean PBS won't work either. Part of the reason I tried scie-pants is because Termux only provides the latest version of python, which right now means 3.11, so pants can't run here yet.
f
p
Yeah
e
@proud-dentist-22844 is this termux stuff for personal use? This is a fairly exotic platform to support (I use termux too, but). It would be good if you could add some sort of note to the two issues you filed. I tend to take user filed issues pretty seriously and move quickly to fix, but this is honestly a big can of worms - how do I CI this stuff to prevent backslide? If this is just for you and you want to put in the effort to fix with no guarantees against backslide (because of lack of CI), that's fine of course.
p
I do things on termux when it is more convenient than pulling out a laptop. I was excited for aarch64 support in pants precisely so I can't use pants on my phone. I believe mobile is an increasingly important platform, but that is hand waving at this point as I don't have data to back that up. Sadly, Google has pushed Termux out of the play store and the APIs are tightening up making things like Termux more difficult to provide. So, Termux is niche, yes. But I'd like some way to support development on phones. I have a cousin that was trying to learn python for awhile, but all they had was a phone, so they were only able to do things when they borrowed someone's computer. It would be nice if the build tooling supported people like that. I would love to see more ways for people to contribute when they only have a phone. Termux is likely not the long term answer. Perhaps some kind of IDE built with Toga+Briefcase and other Beeware products that can target deploying to mobile. I have yet to see such a thing. For me, Termux is the closest I've come to development on mobile. So, I'm admittedly pushing the limits here.
So, that was a very wishy washy response. If you would rather close my issue, that's ok. Windows is likely much higher priority as the next platform to support.
e
I don't care about closing it, I just care it is scoped. If you state clearly you're willing to work on those issues and you don't mind backslide, that's perfectly fine. It allows me to be less worried about backlog.
p
State on the issue?
e
Please. I run my life by issues. If you can self-assign that makes it even more crystal clear.
p
Ok. Will do.
c
Out of curiosity, isn’t a phone screen very small to work on? I guess if it’s the only device you have it is infinitely better than nothing, but I have a hard time imagining I would use a phone ever if there were alternatives..
p
Yes. But there are many times where I don't have my laptop available. Also, my wife teases me for the small font size I use on my phone.
👀 1