when i u0_a235
pkg install termux-api
-bash: /data/data/com.termux/files/usr/bin/pkg: Permission denied
when i root
You should not use command 'apt' as root.
This is dangerous as may damage your Termux installation and data.
so i cant use pkg or apt on every user what should i do?
You have used apt as root at some point which has messed up file permissions.
Easiest fix would be to run rm -rf $PREFIX (as root if necessary) and then restart termux. This will remove all installed packages and give you a fresh installation, but leave $HOME intact
Apt is now permanently locked against running as root.
If you use Termux from ADB or other root thing, you need to su back to Termux user in order to install package.
The error you have -
$ pkg install termux-api
-bash: /data/data/com.termux/files/usr/bin/pkg: Permission denied
comes from messing up with root permissions.
Most helpful comment
Apt is now permanently locked against running as root.
If you use Termux from ADB or other root thing, you need to su back to Termux user in order to install package.