Android: 7.1.2 (Nougat)
Termux version: 0.62
I've had my device's internal memory wiped when I updated to the latest release and ran "termux-setup-storage" in the terminal. To confirm, I created a few files and ran the command again which again wiped the phone's internal memory.
I've encountered this on my OnePlus 3t and a friend's Redmi Note 5, both running android 7.1.2 (Nougat).
@porasjeet Just run termux-setup-storage twice and got wiped aswell.
@fornwall This is a serious issue and perhaps it is introduced in https://github.com/termux/termux-app/commit/bbd46a763ce98507c5ae275ac315d4ebd9ad410a. Maybe we should revert this temporarily ?
Not sure if the storage has been completely wiped or just unmounted though.
Also theoretically there should've been a confirmation dialog of sorts before files get deleted.
@rjt-rockx It is probably a bug. Only ~/storage with symlinks should be deleted but not entire /sdcard.
That was bad. I'm so sorry for this critical issue!
This has been fixed in version 0.63, which has been submitted to the Play store as an update. The release has been tagged so should be available also on F-Droid soon.
Thanks to everyone involved who reported and helped with understanding and fixing the problem!
@fornwall
Android: 7.1.2 (Nougat)
Termux version: 0.62
i ran termux-setup-storage on my android device for access my internal memory.
But when i ran the command the phone storage wiped.
Now what i do?
if latest version of termux(.063) fixed the problem,then what i do now for my delleted data?
Is there any way to recover my all data?
Thanks
@jisan0010 Check out one of the numerous guides online, for example https://forum.xda-developers.com/showthread.php?t=2462426. Note that I haven't tried it.
It might be possible to restore some of the data. Don't use your phone before you try restoring it as new files will overwrite the deleted data.
to get back some files?
To get back some files, make sure that the following conditions are met:
If all these conditions are met, then you can dump data partition somewhere, e.g. external sdcard, and perform recovery on PC (there plenty of free/paid software to do this).
dump data partition:
Can be done using dd over ADB. Example:adb shell dd if=/dev/block/mmcblk0p8 of=/ext_sdcard/mydata.img.
File recovery from unencrypted partition dump is the only reliable way. For other (easier) ways see https://forum.xda-developers.com/showthread.php?t=2462426.
If you don't have root and data encryption enabled (on Android 6.0+ it enabled by default), you are out of luck, unfortunately. Modern Android devices designed in way that prevents (or makes it very hard) access to data bypassing Android OS.
Also, you should know that deleted files continue exist as unallocated space. Shortly: the longer you use your device the less probability of successfull data recovery.
In addition to everything I wrote above - it is better to ask such questions somewhere on XDA in threads related to your device. Here is a Termux Application issue/bug tracker and not a data recovery center...
It is fixed in official Termux 0.65. Proof:

If you still want to use old Termux versions - expect to have all bugs that they contain.
If you managed to place your files to directory ~/storage - then no one will help you. This directory completely managed by Termux, and to prevent file clashes it completely wipes it (note that your sdcard is untouched) - expected behaviour.
The purpose of directory ~/storage is to provide a symlinks to shared and external storage, like /mnt directory.
The bug was device's internal memory wiped and it was fixed. But wiping of ~/storage is intentional.
Most helpful comment
That was bad. I'm so sorry for this critical issue!
This has been fixed in version 0.63, which has been submitted to the Play store as an update. The release has been tagged so should be available also on F-Droid soon.