Heyo all. First-time poster.
So...I need to create a temp directory in the local OSes defined $TMPDIR. For current macOS - that ends up being in
/var/folders which isn't normal user writable. Has anyone else already figured out the workaround, other than spec'ing a diff $TMPDIR when running the Rust-based app? Or is that it?
$TMPDIR on macOS should point to a per-user automatically generated path under
/var/folders which the user does have write access to (they own the directory). It least, this is how it works on my macs.
When I get
$TMPDIR using the
std::env function it seems to behave the way @blonk indicated
// /var/folders/fx/74571y8x0d7__sd6fwtdhrjw0000gn/T/ <- owned by current logged-in user
Thanks peeps. Unfortunately I think I'm running into some "enterprise" security things for the first time - actually kind of surprised. That said, I'm seeing this "no perms" to the $TMPDIR on both my MBP and in a GitHub Action using "macos-latest". Anywho, the easy work around is to simply override with
TMPDIR=$HOME/tmp cargo test. FWIW, that however DOES NOT work on Winders.
If it's OK to use a different directory, then perhaps have a look at the one of the following crates:
dirs - Rust (I've found this makes it easy to use common directories like $HOME, and it seems to have good cross-platform support), or
temp_dir - Rust (it seems to have issues on windows) .
There might also be some other things in
std::env to help.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.