/system/etc/mkshrc[9]: getprop: not found
android:/data/data/com.termux/files/home $
android:/data/data/com.termux/files/home $getprop
sh: getprop: not found
It was working fine. I did nothing unusual. My .bash_history has nothing unusual either. Now when I open, I get this error. Any command I type in is not found. There was no update to my system/phone. I opened the failsafe session and system/etc/mkshrc has a getprop line to get device id at line 9. If I type in getprop here, I get all props.
There's no /etc in my com.termux/files/usr/ . There is no
.profile
.bash_profile
.bashrc
in my home directory(All other files are present). .termux is empty. I removed it in any case. What to do?
There's no /etc in my com.termux/files/usr/
@Blocked How is that possible ? What else is missing ? bin/login or bin/bash ?
I did nothing unusual
My .bash_history has nothing unusual either.
Deleting files with rm is not unusual. And strange effects of this (like something not working) is not unusual too.
@Blocked So what you actually did to break your installation ?
@xeffyr Thanks for the reply. But I think this is because I'm in the failsafe session and symlinks failed? I'm not sure. There's no /bin in com.termux/files/usr/ either. The folders in my usr now(in failsafe session) are:
include
lib
libexec
man
share
tmp
var
My last 5 bash commands:
git checkout ..
git tag v3.1 ...
git tag ..
git tag v3.9 ..
git tag
exit
exit
The last rm command was almost 100-200 lines before. That too only on a home file. I do remember getting a unusual exit code(instead of usual 127). But that happens often, so I don't remember.
Note: Though I can input commands in normal session, All commands return command is not found , where command is the command entered.
EDIT: In normal session, most commands are not found. I can cd but ls not found.
here's no /bin in com.termux/files/usr/ either.
@Blocked That was LOL. Assume that you just deleted critical part of OS on your computer.
My last 5 bash commands:
git checkout ..
git tag v3.1 ...
git tag ..
git tag v3.9 ..
git tag
exit
Ok, I figured out that you did. You used git to manage stuff in /usr. Never use git for such purposes !
In checkout, rebase and other similar commands, git will delete files before putting ones from different revision.
Just remember that git is a revision control system and not backup tool.
Now, move your necessary files from $HOME to /sdcard, then completely reinstall Termux. And remember: we are not responsible about misuse of command line tools or Termux application.
@xeffyr
You used git to manage stuff in /usr.
That's not possible. The git commands were in my .bash_history. But It was scoped to a specific folder in my $HOME directory com.termux/files/home/dir1/project1/. I didn't touch usr.. I've never used to go to usr, unless I install some applications.
I used the failsafe session described here: https://wiki.termux.com/wiki/Recover_a_broken_environment#Possible_broken_dotfiles
You are now in a Failsafe Session. It launches the default Shell of Android /system/bin/sh with access to the Termux directory
So, maybe that's why /bin and /etc is not present.
You are now in a Failsafe Session. It launches the default Shell of Android /system/bin/sh with access to the Termux directory
So, maybe that's why /bin and /etc is not present.
@Blocked No. It just launches /system/bin/sh instead of $PREFIX/bin/login.
But anyway, you used something that removed $PREFIX/bin. This is not a Termux's fail.
And it is not possible to repair environment that was broken in such way.
@xeffyr Aren't they kind of symlinked? Maybe because mkshrc failed, It didn't link or something like that? Regardless, I didn't setup-storage and I obviously can't now either. So,how can I recover my $HOME ? Is it possible to put some bin files back in for the backup.
The above link states,
Remove $PREFIX entirely.
rm -rf /data/data/com.termux/files/usr
After that you can restart your Termux App completely, which will trigger a reinstallation of the default $PREFIX contents. You'll have to reinstall all your programs, but your $HOME folder remains untouched, so all your dotfiles are still there.
So, Can I trigger that and save my $HOME ?
EDIT:Also, Will there be logs somewhere else in cache or tmp, so that I can see what happened?
Or maybe I can change shells from failsafe?
Aren't they kind of symlinked? Maybe because mkshrc failed, It didn't link or something like that?
@Blocked Mkshrc (and whole /system/bin) has no relation to Termux environment ($PREFIX). Usually mkshrc errors appear when Termux launches /system/bin/sh instead of $PREFIX/bin/login. It throws errors because env vars $PATH and $LD_LIBRARY_PATH are wrong for /system/etc/mkshrc.
See how login shell is chosen (snippet from termux-app):
``` .java
if (executablePath == null) {
for (String shellBinary : new String[]{"login", "bash", "zsh"}) {
File shellFile = new File(PREFIX_PATH + "/bin/" + shellBinary);
if (shellFile.canExecute()) {
executablePath = shellFile.getAbsolutePath();
break;
}
}
if (executablePath == null) {
// Fall back to system shell as last resort:
executablePath = "/system/bin/sh";
}
isLoginShell = true;
}
$PREFIX is a standalone environment with no external deps with exception for Android's libc, libdl, liblog and some more.
> rm -rf /data/data/com.termux/files/usr
> So, Can I trigger that and save my $HOME ?
Home is located in `/data/data/com.termux/files/home`, so when you remove `usr`, your home will be saved. I actually do this when I need to quickly get a fresh environment.
You can even do this:
mv /data/data/com.termux/files/usr /data/data/com.termux/files/usr.bak
```
- this will rename $PREFIX instead of deleting. But after reopening Termux application a new $PREFIX will be installed.
@xeffyr mv worked. Had to re-install and set up everything again... But no permanent damage. Only wish I knew what caused this: some rogue program... or anything I did...
Thanks for all your help.
Tip for others: $HOME was also freely accesible in the inbuilt-Files App; In case, anyone wants to backup without setup-storage.
Most helpful comment
@Blocked Mkshrc (and whole /system/bin) has no relation to Termux environment (
$PREFIX). Usually mkshrc errors appear when Termux launches /system/bin/sh instead of $PREFIX/bin/login. It throws errors because env vars$PATHand$LD_LIBRARY_PATHare wrong for /system/etc/mkshrc.See how login shell is chosen (snippet from termux-app):
``` .java
if (executablePath == null) {
for (String shellBinary : new String[]{"login", "bash", "zsh"}) {
File shellFile = new File(PREFIX_PATH + "/bin/" + shellBinary);
if (shellFile.canExecute()) {
executablePath = shellFile.getAbsolutePath();
break;
}
}
mv /data/data/com.termux/files/usr /data/data/com.termux/files/usr.bak
```
- this will rename $PREFIX instead of deleting. But after reopening Termux application a new $PREFIX will be installed.