termux-play-store / termux-apps

Source for the Termux build on Google Play.
https://play.google.com/store/apps/details?id=com.termux
Other
35 stars 1 forks source link

[Bug]: Certain executables not working on the Play Store version, but do work in FDroid version #23

Open marcoismobile opened 3 days ago

marcoismobile commented 3 days ago

Problem description

Not sure how to describe the problem, but it seems after switching to the Play Store version of Termux, certain executables are not working anymore. I am not sure if they have the same root cause, so I am creating this issue to get some pointers on how to investigate/troubleshoot or possibly fix these problems ;)

Chezmoi: https://www.chezmoi.io/user-guide/use-scripts-to-perform-actions/ When trying to apply Chezmoi it is going to run some 'generated' install shell scripts, this is working without problems on the Fdroid version of Termux, but it will gives the following error on the Play Store version:

xxx.install.sh has bad ELF magic: 23212f64

Powerlevel10k: https://github.com/romkatv/powerlevel10k?tab=readme-ov-file#why-does-powerlevel10k-spawn-extra-processes When installing Powerlevel10k zsh extention, it downloads a 'gitstatus' executable, which works fine on the Fdroid version of Termux, but gives the following error on the Play Store version:

Could not find a PHDR: broken executable?

I am not sure where to look or how to troubleshoot this? Can it possible be related to 'External, non-Termux app can not yet run Termux commands (the RUN_COMMAND permission).' or is that a compleet wrong direction?

Please let me know if you want me to troubleshoot more or need more debug logs etc.. Thanks in advance!

Steps to reproduce the behavior.

What is the expected behavior?

Normal working functionality as in the Fdroid version of Termux

System information

sleirsgoevy commented 2 days ago

This "ELF magic" looks like a start of a shell script shebang. Looks like shebangs might be unsupported yet?

sleirsgoevy commented 2 days ago

It seems that termux-exec only supports the shebang pointing directly to an ELF file. Linux actually supports nested shebangs, where an interpreter of a script is a shebanged script itself.

gitstatus is probably a statically-linked executable, see here.

fornwall commented 2 days ago

Thanks for reporting @marcoismobile, and thanks for looking into this @sleirsgoevy !

It seems that termux-exec only supports the shebang pointing directly to an ELF file. Linux actually supports nested shebangs, where an interpreter of a script is a shebanged script itself.

Good find, seems to be the case (needs to be fixed)!

fornwall commented 2 days ago

gitstatus is probably a statically-linked executable, see here.

One way around that would be to provide a Termux gitstatus package, which would be dynamically linked. Don't know how straightforward it would be to make Powerlevel10k use a system-provided gitstatus binary, instead of downloading the statically linked one?

erhenjt commented 2 days ago

Actually I rememberwd I was able to get a statically-linked executable to run withchmod / (Which would returnhas unexpected e_type: 2if executed directly), but it would require a rooted device. Not sure whether proot would do the same on non-rooted devices?

marcoismobile commented 2 days ago

Thanks both for the quick replies! This indeed make sense (that it is related to the shebangs). Do I understand correctly that this 'shebangs' (or the termux-exec package) is not used for the Fdroid version of Termux? Or is it used in another way? Because the downloaded version of gitstatus is working 'out-of-the-box' on the Fdroid version (same for the chezmoi scripts).

Is there a way to test above in some way by manually change things? I tested a normal shell script.sh:

#!/bin/bash
echo Test123

Which is working fine, so I assume this is triggering 'shebangs' in some other way?