Closed surban closed 3 months ago
I'd like to hear a few more details on what you're trying to do here. In general:
std::env::set_var
early at startup. Although, TBH, you should really just use the default specified by the user.We are writing a Rust dynamic library that is loaded into a bigger program. We do not control when the library is loaded and initialized, thus multiple threads might already be running. For some OS (for example Android) we need to manually set the TMPDIR location, since the default path is inaccessible.
If you don't like the idea, a workaround would be to use $HOME/cache/tmp
on Android, since $HOME
points to the package directory and thus should be writable. This would probably already account for 90% of the use cases.
We use https://doc.rust-lang.org/std/env/fn.temp_dir.html. Are you sure you're compiling for the right target?
Yes, but /data/local/tmp
is not accessible anymore in recent Android versions.
That's... really annoying. Apparently new enough versions of android may set TMPDIR (according to a random internet comment that I probably shouldn't trust).
I'll add an override.
@surban please review #286. Also, would you mind contributing a test case (make a PR against that PR)?
That's... really annoying. Apparently new enough versions of android may set TMPDIR (according to a random internet comment that I probably shouldn't trust).
I'll add an override.
Tested with Google Pixel 8 and latest update. TMPDIR
is not set in a package context, i.e. adb shell run-as <package> printenv TMPDIR
is empty.
Tested with Google Pixel 8 and latest update. TMPDIR is not set in a package context, i.e. adb shell run-as
printenv TMPDIR is empty.
Then I guess the random internet comment was a lie (and google really needs to fix their shit).
Now that
std::env::set_var
is unsafe and essentially unusable anymore, it would be great if tempfile provided a method to override the global temporary directory on UNIX.