Feature description
Not sure if this is something Termux developers have a say in at all, but recently I accidentally deleted the Termux app^1. However, this deleted all of my files termux related files (including scripts, and a ton of music that I copied over with Linux utilities), contrary to all expectations I've aqcuired about deleting apps and managing software under Linux. It just seems like bad design to delete more than just the app (and maybe stuff installed with pkg).
I can see how this happened by my own mistake or was inevitable because I had all my files in Termux owned folders. Still, it seems rather strange that app deletion would mess with non-Termux essential stuff on my SD card too.
If this is something that can be changed, I would highly suggest to delete as little as possible when the Termux app is deleted, because this amount of data loss is incredibly frustrating and unnecessary. If some user desires to cleanup Termux related configuration, there are other utilities to deal with that (e.g. the native Files app)
If someone knows a way to undo what I did or avoid it, please let me (and future others) know!
Reference implementation
No OSs (at least iOS, macOS and Linux)/package managers/other terminal apps (esp. with a linux-y mindset) delete user data when an app or package is deleted. (e.g. pacman leaves stuff in ~/.config in place). At least certainly not someone's $HOME or stuff on a SD card.
I accidentally deleted the Termux app
However, this deleted all of my files termux related files
Yes, application deletion will erase everything under:
It is not possible to prevent deletion of data under these directories. Application and data deletion is handled by Android OS and we cannot do anything with this.
I would highly suggest to delete as little as possible
I can only suggest to keep files somewhere under /sdcard/documents/.... Do not store your files under directories managed by Android.
If some user desires to cleanup Termux related configuration, there are other utilities to deal with that
Termux environment cleanup != Termux deletion.
No OSs (at least iOS, macOS and Linux)/package managers/other terminal apps (esp. with a linux-y mindset) delete user data
Unfortunately, when you delete Termux application, you are dealing with Android Package Manager which deletes user data from:
Why would I need something like a failsafe shell on a phone where the terminal is a second class citizen?
Just assume that you instead of deleting application messed with configuration files and Termux cannot start session.
In such case you will ask for a way to extract your files from /data/data/com.termux directory which is inaccessible without root. That is for what failsafe shell required.
by for example connecting with ssh [IP] -t safe_shell
And how SSH will work if:
Perhaps SSH easily becomes non-reliable solution ?
I guess we can remove "failsafe" icon in next app version. Just to avoid confusion.
Hope that no one will cry to add it back...
We did talk about moving the failsafe activity to a new app, so that it is optional, and users then can install it if they run into problems and need a failsafe session.
Also, to avoid data loss in the future, do regular backups of important folders and store them in /sdcard or /storage/{external sdcard}/
Regarding backup way described in https://wiki.termux.com/wiki/Package_Management#Backup_and_restore_Termux_installation: these instructions are mostly for reference how it should be done, better to use script to automate this process. For example like this one termux-backup.txt which I use.
Thanks for the reply, I understand that there is no fix for this except for being extra careful where you place your files.
And how SSH will work if:
It is not installed.
It's daemon was not started.
It's daemon cannot be started due to missing libs or broken config.
???
My suggestion was more that having a full on failsafe app is overdoing it. In the extremely rare case that you want to mess with important libs (I'm not even sure what kind of essential libs/software you're thinking of and why and how you want to change them) on your non-rooted phone you can easily circumvent any potential problems by ensuring that your 1. ssh client is running and works 2. you have a working basic shell. The modularity of Linux makes it so that any problem you create in one package is very unlikely to spread to others. Apart from ssh, I'm sure hardcore Linux users (which are the only ones that need to mess with essentials anyway) can think of other ways to build failsafe environments.
I suppose you can screw up your bash profile when first configuring it, leaving you without failsafe options, but reinstalling won't be much effort in this case.
Maybe just adding a preference option within the app (or in the system preferences, if that is possible in Andriod) to start Termux with busybox/change the login shell would be handy (most desktop terminal apps have an option like this)
I suppose you can screw up your bash profile when first configuring it, leaving you without failsafe options, but reinstalling won't be much effort in this case.
The reason having a failsafe option is considered so important is that you loose all your files on reinstall, so if someone messes with .bashrc they may inadvertently loose access to all of their files without any method of getting them back, other than the failsafe option.
It's a bit ironic that functionality which was created to prevent loss of files caused you to loose your files though :/
Most helpful comment
Yes, application deletion will erase everything under:
It is not possible to prevent deletion of data under these directories. Application and data deletion is handled by Android OS and we cannot do anything with this.
I can only suggest to keep files somewhere under
/sdcard/documents/.... Do not store your files under directories managed by Android.Termux environment cleanup != Termux deletion.
Unfortunately, when you delete Termux application, you are dealing with Android Package Manager which deletes user data from:
Just assume that you instead of deleting application messed with configuration files and Termux cannot start session.
In such case you will ask for a way to extract your files from /data/data/com.termux directory which is inaccessible without root. That is for what failsafe shell required.
And how SSH will work if:
???
Perhaps SSH easily becomes non-reliable solution ?