[Bug]: `termux-exec` didn't work with `libtoolize` for unknown reason
Problem description
Title: Path Hardcoding Issue in libtoolize for Termux Installation
Issue Description:
Upon installing libtool via apt in Termux, the script libtoolize contains hardcoded paths that lead to an incorrect usage of system binaries. Specifically, it still references /usr/bin/ instead of $PREFIX/bin/, causing issues when running libtoolize. This is preventing proper operation as the expected paths are incorrect, even after updating the package.
Steps to Reproduce:
-
Install the
libtoolpackage in Termux:apt install libtool -
Run the
libtoolizeversion command:libtoolize --versionOutput will show errors about missing dependencies like
sedorgrep, which are incorrectly referenced as/usr/bin/. -
Check the
libtoolizefile and observe that it still contains hardcoded/usr/bin/paths:grep -r '/usr/bin/' $(which libtoolize)It will show paths like:
: ${EGREP="/usr/bin/grep -E"} : ${FGREP="/usr/bin/grep -F"} : ${GREP="/usr/bin/grep"} : ${SED="/usr/bin/sed"} -
Modify the
libtoolizescript usingsedto correct the paths:sed -i '/^#!/!s|/usr/bin/|'"$PREFIX"'/bin/|g' $(which libtoolize) -
After running the above command,
libtoolizewill work correctly without errors:libtoolize --version
Expected Behavior:
The libtoolize script should dynamically use $PREFIX/bin/ paths instead of hardcoding /usr/bin/, ensuring that it works correctly within the Termux environment.
Environment:
- Termux Version: 0.118.1
- Android Version: 11
- Device Model: realme RMX3085
- Architecture: aarch64
- Installed Repositories: grimler.se, tur.kcubeterm.com, its-pointless.github.io, etc.
Additional Notes:
This issue could be a result of an outdated or improperly configured libtool package for Termux. It would be helpful to modify the script to use $PREFIX/bin/ instead of /usr/bin/ to avoid similar issues in the future.
What steps will reproduce the bug?
- Install the
libtoolpackage in Termux:apt install libtool - Run the
libtoolizeversion command:libtoolize --version```
To wit:
~/pkgconf $ apt reinstall libtool
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
libtool
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/391 kB of archives.
After this operation, 2851 kB of additional disk space will be used.
Selecting previously unselected package libtool.
(Reading database ... 218679 files and directories currently installed.)
Preparing to unpack .../libtool_2.5.4_aarch64.deb ...
Unpacking libtool (2.5.4) ...
Setting up libtool (2.5.4) ...
Processing triggers for man (1.14.6-1) ...
~/pkgconf $ libtoolize --version
/data/data/com.termux/files/usr/bin/libtoolize: 1: /usr/bin/sed: not found
(GNU libtool) 2.5.4
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Gary V. Vaughan <[email protected]>, 2003
What is the expected behavior?
~/pkgconf $ libtoolize --version
libtoolize (GNU libtool) 2.5.4
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Gary V. Vaughan <[email protected]>, 2003
~/pkgconf $
(after my patch)
System information
See above
Same thing happens to libtool, so:
sed -i '/^#!/!s|/usr/bin/|'"$PREFIX"'/bin/|g' $(which libtool)
It is weird, as I had been using Termux for years and never encountered this error. BTW, I need this libtool* for compiling this in turn:
~/pkgconf $ ls
aclocal.m4 bomtool config.guess configure depcomp Kyuafile.in libpkgconf.pc.in Makefile man NEWS tests
AUTHORS cli config.log configure.ac doc libpkgconf libtool Makefile.am meson.build pkg.m4
autogen.sh CODE_OF_CONDUCT.md config.status configure~ install-sh libpkgconf.la ltmain.sh Makefile.in meson_options.txt pkgconf
autom4te.cache compile config.sub COPYING Kyuafile libpkgconf.pc m4 Makefile.lite missing README.md
~/pkgconf $
which advises to run: libtool --finish $PREFIX/local/lib - pkgconf being needed for motion compilation without glibc-runner...
A Matrioshka doll of such errors.
@Manamama what's interesting is that I can reproduce this problem with the grep -r '/usr/bin/' $(which libtoolize) command, which shows what you show for me also,
#!/data/data/com.termux/files/usr/bin/env sh
: ${EGREP="/usr/bin/grep -E"}
: ${FGREP="/usr/bin/grep -F"}
: ${GREP="/usr/bin/grep"}
: ${SED="/usr/bin/sed"}
but I cannot reproduce this with the libtoolize --version command, which completes without errors for me.
libtoolize (GNU libtool) 2.5.4
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Gary V. Vaughan <[email protected]>, 2003
The reason is because, on my device, termux-exec is causing the command /usr/bin/grep to complete successfully
~ $ apt-cache policy termux-exec
termux-exec:
Installed: 1:2.3.0
Candidate: 1:2.3.0
Version table:
*** 1:2.3.0 500
500 https://mirror.rinarin.dev/termux/termux-main stable/main aarch64 Packages
100 /data/data/com.termux/files/usr/var/lib/dpkg/status
~ $ /usr/bin/grep
Usage: /usr/bin/grep [OPTION]... PATTERNS [FILE]...
Try '/usr/bin/grep --help' for more information.
~ $
termux-exec is a Termux component that has the power to, in most cases, cause /usr/bin commands to be automatically intercepted and redirected to /data/data/com.termux/files/usr/bin commands in real time. That is why this issue is difficult to reproduce for most people, but a few people do encounter this.
There is an open PR to help with this by a known user of a termux-exec-less copy of Termux, but it has some problems.
I'll help with that PR to get it ready to solve this.
- https://github.com/termux/termux-packages/pull/24088
Possible causes I can think of for this discrepancy:
- Maybe you have a missing or outdated version of
termux-exec - Maybe your
termux-execis up to date, but it is failing to work correctly on your specific device or version of the Termux APK - Maybe your
termux-execis configured into a mode which isn't intercepting your/usr/bincommands
In the mean time, could you try these additional troubleshooting steps to collect more information about what could be happening on your device?
pkg upgrade -yto upgrade all packagesapt-cache policy termux-execto show yourtermux-execversion- complete
termux-infooutput without summarizing the contents, to look forLD_PRELOADconfiguration variable status and other possible relevant information - if
termux-execis upgraded bypkg upgrade -yfor you, remember to close the Termux session withexitand open a new one to apply the change, becausetermux-execupdates do not take effect until you do that.
Mine looks standard:
~/downloads $ apt-cache policy termux-exec
termux-exec:
Installed: 1:2.3.0
Candidate: 1:2.3.0
Version table:
*** 1:2.3.0 500
500 https://grimler.se/termux/termux-main stable/main aarch64 Packages
100 /data/data/com.termux/files/usr/var/lib/dpkg/status
~/downloads $ uname -a
Linux localhost 4.14.186+ #1 SMP PREEMPT Thu Mar 17 16:28:22 CST 2022 aarch64 Android
~/downloads $ libtool --version
libtool (GNU libtool) 2.5.4
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Originally written by Gordon Matzigkeit, 1996
(See AUTHORS for complete contributor listing)
~/downloads $ apt reinstall libtool
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 21 not upgraded.
Need to get 0 B/391 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 221541 files and directories currently installed.)
Preparing to unpack .../libtool_2.5.4_aarch64.deb ...
Unpacking libtool (2.5.4) over (2.5.4) ...
Setting up libtool (2.5.4) ...
Processing triggers for man (1.14.6-1) ...
~/downloads $ libtool --version
/data/data/com.termux/files/usr/bin/libtool: line 974: /usr/bin/sed: No such file or directory
(GNU libtool) 2.5.4
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Originally written by Gordon Matzigkeit, 1996
(See AUTHORS for complete contributor listing)
~/downloads $
termux-info
Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=20511
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.1
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://grimler.se/termux/termux-main stable main
# x11-repo (sources.list.d/x11.list)
deb https://grimler.se/termux/termux-x11 x11 main
# tur-repo (sources.list.d/tur.list)
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
# root-repo (sources.list.d/root.list)
deb https://grimler.se/termux/termux-root root stable
# sources.list.d/pointless.list
deb https://its-pointless.github.io/files/21 termux extras
# sources.list.d/termux-adb.list
deb https://nohajc.github.io termux extras
# glibc-repo (sources.list.d/glibc.list)
deb https://packages-cf.termux.dev/apt/termux-glibc/ glibc stable
Updatable packages:
at-spi2-core/stable 2.56.1-1 aarch64 [upgradable from: 2.56.1]
binutils-bin/stable 2.44-3 aarch64 [upgradable from: 2.43.1]
binutils-gold/stable 2.44-3 aarch64 [upgradable from: 2.43.1]
binutils-libs/stable 2.44-3 aarch64 [upgradable from: 2.43.1]
binutils/stable 2.44-3 aarch64 [upgradable from: 2.43.1]
clang/stable 20.1.2 aarch64 [upgradable from: 19.1.7]
command-not-found/stable 2.4.0-70 aarch64 [upgradable from: 2.4.0-69]
gdk-pixbuf/stable 2.42.12-1 aarch64 [upgradable from: 2.42.12]
glib-bin/stable 2.84.1 aarch64 [upgradable from: 2.84.0-1]
glib/stable 2.84.1 aarch64 [upgradable from: 2.84.0-1]
gtk-layer-shell/x11 0.9.1 aarch64 [upgradable from: 0.9.0]
gtk-update-icon-cache/x11 3.24.49-1 aarch64 [upgradable from: 3.24.49]
gtk3/x11 3.24.49-1 aarch64 [upgradable from: 3.24.49]
harfbuzz-icu/stable 11.0.1 aarch64 [upgradable from: 11.0.0]
harfbuzz/stable 11.0.1 aarch64 [upgradable from: 11.0.0]
imlib2/stable 1.12.5 aarch64 [upgradable from: 1.12.4-1]
libcairo/stable 1.18.4-1 aarch64 [upgradable from: 1.18.4]
libcompiler-rt/stable 20.1.2 aarch64 [upgradable from: 19.1.7]
libicu/stable 77.1-1 aarch64 [upgradable from: 77.1]
libllvm/stable 20.1.2 aarch64 [upgradable from: 19.1.7]
liblzma/stable 5.8.1 aarch64 [upgradable from: 5.8.0]
libsecret/stable 0.21.7-1 aarch64 [upgradable from: 0.21.7]
libvte/x11 2:0.80.0-2 aarch64 [upgradable from: 2:0.80.0-1]
lld/stable 20.1.2 aarch64 [upgradable from: 19.1.7]
llvm/stable 20.1.2 aarch64 [upgradable from: 19.1.7]
llvmgold/stable 20.1.2 aarch64 [upgradable from: 19.1.7]
mesa-dev/stable 25.0.3-1 all [upgradable from: 25.0.3]
mesa-vulkan-icd-swrast/stable 25.0.3-1 aarch64 [upgradable from: 25.0.3]
mesa/stable 25.0.3-1 aarch64 [upgradable from: 25.0.3]
mlir/stable 20.1.2 aarch64 [upgradable from: 19.1.7]
pango/stable 1.56.3-1 aarch64 [upgradable from: 1.56.3]
patch/stable 2.8 aarch64 [upgradable from: 2.7.6-4]
qpdf/stable 12.1.0 aarch64 [upgradable from: 12.0.0]
ruff/stable 0.11.4 aarch64 [upgradable from: 0.11.2]
rust-std-aarch64-linux-android/stable 1.86.0 all [upgradable from: 1.85.1]
rust/stable 1.86.0 aarch64 [upgradable from: 1.85.1]
vulkan-headers/stable 1.4.312 all [upgradable from: 1.4.311]
vulkan-loader-generic/stable 1.4.312 aarch64 [upgradable from: 1.4.311-1]
xz-utils/stable 5.8.1 aarch64 [upgradable from: 5.8.0]
termux-tools version:
1.45.0
Android version:
11
Kernel build information:
Linux localhost 4.14.186+ #1 SMP PREEMPT Thu Mar 17 16:28:22 CST 2022 aarch64 Android
Device manufacturer:
realme
Device model:
RMX3085
Supported ABIs:
SUPPORTED_ABIS: arm64-v8a,armeabi-v7a,armeabi
SUPPORTED_32_BIT_ABIS: armeabi-v7a,armeabi
SUPPORTED_64_BIT_ABIS: arm64-v8a
LD Variables:
LD_LIBRARY_PATH=/data/data/com.termux/files/home/.local/lib:
LD_PRELOAD=
Installed termux plugins:
com.termux.api versionCode:51
com.termux.x11 versionCode:14
com.termux.boot versionCode:1000
com.termux.styling versionCode:1000
com.termux.widget versionCode:13
Post output of TERMUX_EXEC__LOG_LEVEL=4 libtoolize --version
It is solved using the newest .deb, q.v., updated, but for the record:
TERMUX_EXEC__LOG_LEVEL=4 libtoolize --version
7001 E termux : TERMUX_EXEC__VERSION: 'libtermux-exec-direct-ld-preload version=1:2.3.0 org=termux project=termux-exec-package'
7001 E termux.exec: <----- execve() intercepted ----->
7001 E termux.exec: executable = '/data/data/com.termux/files/usr/bin/libtoolize'
7001 E termux.exec: argv[0] = 'libtoolize'
7001 E termux.exec: argv[1] = '--version'
7001 E termux.exec: Intercepting execve
7001 E termux.exec: read_file_header: '1'
7001 E termux.exec: interpreter_path: '/data/data/com.termux/files/usr/bin/env'
7001 E termux.exec: interpreter_arg: 'sh'
7001 E termux.ld-preload: system_linker_exec_mode: '1'
7001 E termux.ld-preload: android_build_version_sdk: '30'
7001 E termux.ld-preload: se_process_context_from_file: 'u:r:untrusted_app_27:s0:c22,c257,c512,c768'
7001 E termux.ld-preload: app_data_file_exec_exempted: '1'
7001 E termux.ld-preload: system_linker_exec_enabled: '0'
7001 E termux.exec: unset_ld_vars_from_env: '0'
7001 E termux.exec: unset_ld_preload_from_env: '1'
7001 E termux.exec: modify_env: '1'
7001 E termux.exec: Unset 'LD_PRELOAD='
7001 E termux.exec: modify_args: '1'
7001 E termux.exec: Calling syscall execve
7001 E termux.exec: executable = '/data/data/com.termux/files/usr/bin/env'
7001 E termux.exec: argv[0] = '/data/data/com.termux/files/usr/bin/env'
7001 E termux.exec: argv[1] = 'sh'
7001 E termux.exec: argv[2] = '/data/data/com.termux/files/usr/bin/libtoolize'
7001 E termux.exec: argv[3] = '--version'
libtoolize (GNU libtool) 2.5.4
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Gary V. Vaughan <[email protected]>, 2003
[1]+ Done updatedb
~ $
It is solved using the newest .deb, q.v., updated, but for the record:
Closing as resolved.
It is solved using the newest .deb, q.v., updated, but for the record:
Closing as resolved.
I am not sure which .deb of what package was meant by this
This deb: https://github.com/termux/termux-packages/pull/24088#issuecomment-2784502853
Oh that PR is still open. I didn't see that there was one linked to this issue initially. GitHub seems to have updated the UI for that.
I'll reopen this issue, it can be closed by that PR when it is merged.
This deb: #24088 (comment)
I see, well I believe this combination of behaviors on your device indicates you could have a configuration problem with your termux-exec, particularly the LD_PRELOAD and LD_LIBRARY_PATH variables.
LD_LIBRARY_PATH=/data/data/com.termux/files/home/.local/lib:LD_PRELOAD=
Frequently, these settings can cause a problem for people.
@Manamama if you continue to experience any problems like this, please explain what you need the LD_LIBRARY_PATH setting and LD_PRELOAD unset for.
These variables should look something more like this, not like how you have them.
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec-ld-preload.so
I would suggest maybe trying this command to reset your termux-exec settings, but I am not sure if it is appropriate. It is possible that maybe agnostic-apollo knows the correct commands to fix the settings of termux-exec.
pkg upgrade -y
pkg reinstall termux-exec
TERMUX_EXEC__LOG_LEVEL=4 libtoolize --version was meant to be run on old version, reinstall and then run again, with LD_PRELOAD already being set of course and new shell started.
Thank you for persistence. However, as it works now (doubly so: either via my original sed trick or that newest deb), so I shall just use that .deb for now and sign off from here.
For why I have such weird preload etc. I do not remember by now, but looking at:
~/downloads $ tree /data/data/com.termux/files/home/.local/lib /data/data/com.termux/files/home/.local/lib ├── ld-linux-aarch64.so.1
├── libm.so.6
├── libpthread.so.0 └── python3.12 └── site-packages
3 directories, 3 files
~/downloads $
I had probably needed some special versions of these, hand compiled (from their sources) for some recondite packages that supposedly would never run on pure (not prooted) Termux: whisperx or maybe:
Name: thinc Version: 8.3.2 Summary: A refreshing functional take on deep learning, compatible with your favorite libraries. (While docling still fails alas, only works in proot).
Ciao and bows
The termux-exec-less compatible libtoolize for people who either prefer not to use termux-exec, or whose termux-exec is having a problem, has been merged, but I will leave this open in case Manamama would like to come back to this and possibly try to figure out why termux-exec didn't seem to be working on their device.