Skip to content

Commit d1f9055

Browse files
committed
auto merge of #8901 : adridu59/rust/issue-8511, r=huonw
Android has no /tmp partition, cf. #8511.
2 parents 91922f0 + 50d4714 commit d1f9055

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/libstd/os.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@ pub fn homedir() -> Option<Path> {
584584
*
585585
* On Unix, returns the value of the 'TMPDIR' environment variable if it is
586586
* set and non-empty and '/tmp' otherwise.
587+
* On Android, there is no global temporary folder (it is usually allocated
588+
* per-app), hence returns '/data/tmp' which is commonly used.
587589
*
588590
* On Windows, returns the value of, in order, the 'TMP', 'TEMP',
589591
* 'USERPROFILE' environment variable if any are set and not the empty
@@ -606,7 +608,11 @@ pub fn tmpdir() -> Path {
606608

607609
#[cfg(unix)]
608610
fn lookup() -> Path {
609-
getenv_nonempty("TMPDIR").unwrap_or_default(Path("/tmp"))
611+
if cfg!(target_os = "android") {
612+
Path("/data/tmp")
613+
} else {
614+
getenv_nonempty("TMPDIR").unwrap_or_default(Path("/tmp"))
615+
}
610616
}
611617

612618
#[cfg(windows)]

0 commit comments

Comments
 (0)