Because I work on a laptop, I was experimenting with different wireless adb apks for Android, having a cable under my hand isn’t too handy. After a few tests I started getting that error:
com.android.ddmlib.InstallException: Unknown failure (/system/bin/sh: pm: can't execute: Permission denied)
Didn’t tell me much. I started Googling… No results. Ok, one result… taking me to Gitlab-CI of my project. So I had this before. I didn’t solve it, don’t know why. Probably because it was when I was experimenting with different ROMs on my another device. So I “fixed” it by reinstalling ROM, and it came back.
Not many things where helpful online so I had to find solution myself and here I present it to you, and to future me, when I have this again.
I hope your device was rooted, you will need it now.
Your /system on Android will be mounted as read-only so you need to remount it as read+write, first switch user to root:
su mount -o rw,remount /system
The problem described at the top, is because something, somehow, changed permission of /system/bin/pw to 000.
It’s enough to do:
chmod 755 /system/bin/pw exit exit
and reboot your phone.