0

I am trying to use pelican (python) on Android (in termux). It fails when pelican tries to write to /tmp which near as I can tell, does not exist, and/or is a read-only file system.

The error is from os.py, in makedirs(name, mode)

OSError: [Errno 30] Read-only file system: '/tmp'
  • How do I tell any sort of script on Android to use a different location for /tmp?
  • How do I tell python on Android (in Termux) to use a different location for /tmp?
  • What is the Android equivalent of /tmp?

Editing to respond to suggestion this is a duplicate:

I found that answer helpful, but it doesn't pertain to this question.

I tried the instructions suggested here: https://stackoverflow.com/a/18280309/608970 and found that by setting TMP, TMPDIR and TEMP that I can indeed change /tmp for python and create tmp files, IF the script uses the tempfile module.

Apparently, pelican does not. Which leaves my original question, in Android what is the model for /tmp, how do we port arbitrary scripts, and does it require a change to the code, or can it be otherwise fixed by changing the Android environment the code works within?

Community
  • 1
  • 1
Jerry Asher
  • 836
  • 2
  • 10
  • 23
  • Possible duplicate of [Where does python tempfile writes its files?](http://stackoverflow.com/questions/18280245/where-does-python-tempfile-writes-its-files) – Peter Wood Sep 13 '16 at 20:19
  • Thanks @PeterWood, I found that answer helpful, but it doesn't pertain to this question. I tried the instructions suggested here: http://stackoverflow.com/a/18280309/608970 and found that by setting TMP, TMPDIR and TEMP that I can indeed change /tmp for python and create tmp files, IF the script uses the tempfile module. Apparently, pelican does not. Which leaves my original question, in Android what is the model for /tmp and how do we port arbitrary scripts? – Jerry Asher Sep 13 '16 at 20:36

2 Answers2

1

According to https://stackoverflow.com/a/41105574/493161, it's /data/local/tmp, but my experience with termux is that it cannot read many/most files and directories that can be seen using adb from the desktop, and has write access to nothing (that I've found) outside its own files. I'd suggest mkdir $HOME/tmp instead, and using that.

Some of the other answers on that same question have good information on the lack of /tmp. Note that /data/local/tmp does not have the sticky ("t") bit set, nor does it have full read/write access to all users, as does Linux.

jcomeau_ictx
  • 37,688
  • 6
  • 92
  • 107
0

A better answer for many use cases is to use the file sharing options built into termux, documented at https://wiki.termux.com/wiki/Sharing_Data

$ termux-setup-storage
$ cp test.png ~/storage/downloads
$ xdg-open ~/storage/downloads/test.png
jcomeau_ictx
  • 37,688
  • 6
  • 92
  • 107