-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set temp directory (override TMPDIR environment) #285
Comments
I'd like to hear a few more details on what you're trying to do here. In general:
|
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 |
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 |
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. |
This adds a new `env` module with `override_temp_dir` and `temp_dir` functions. - `temp_dir` will defer to `std::env::temp_dir` by default unless the temporary directory has been overridden. - `override_temp_dir` allows the user to override the default temporary directory ONCE. Once this value has been set, it cannot be changed Care should be taken to ensure that the chosen directory is actually writable. This API is designed for use by the application author when the application may run in an environment without a reliable global temporary directory (e.g., Android). fixes #285
This adds a new `env` module with `override_temp_dir` and `temp_dir` functions. - `temp_dir` will defer to `std::env::temp_dir` by default unless the temporary directory has been overridden. - `override_temp_dir` allows the user to override the default temporary directory ONCE. Once this value has been set, it cannot be changed Care should be taken to ensure that the chosen directory is actually writable. This API is designed for use by the application author when the application may run in an environment without a reliable global temporary directory (e.g., Android). fixes #285
Tested with Google Pixel 8 and latest update. |
This adds a new `env` module with `override_temp_dir` and `temp_dir` functions. - `temp_dir` will defer to `std::env::temp_dir` by default unless the temporary directory has been overridden. - `override_temp_dir` allows the user to override the default temporary directory ONCE. Once this value has been set, it cannot be changed Care should be taken to ensure that the chosen directory is actually writable. This API is designed for use by the application author when the application may run in an environment without a reliable global temporary directory (e.g., Android). fixes #285
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.The text was updated successfully, but these errors were encountered: