The problem comes from that /sqlite_stmt_journals used to exist and be a world-writable sticky directory, like /tmp is in normal Unix boxen, so I used it as standard TMPDIR when I added mksh to Android.
Recent Android security policy forbids world-writable directories, totally.
We (the Android team and I) are aware of the problem but have yet to come up with a good solution; “user” home directories would need to be created before they can be (automatically) used, but a Googler told me they have something in the queue.
Until then, set TMPDIR to something that is writable for your user.
This is a problem with the Android environment, not with mksh per se.
@Julian Fondren: your Android device is probably from when that directory still existed.
In AOSP git master, the default TMPDIR is /data/local which is writable at least for the root user… so, just set it to something writable for you (and export it if you’re running scripts) for now.