A utility to override the temp directory for an executable, which is written in Rust.
Sometimes, the executables use TMP
and TEMP
for finding the temporary directory. However, when you run them in parallel, it is possible that they will write to a file at the same time. We want to avoid this situation, so this utility is written.
Simple usage
set RANDOMTEMP_EXECUTABLE=set
./randomtemp.exe
:: you may notice that the variables are overriden
export RANDOMTEMP_EXECUTABLE=set
./randomtemp.exe
# you may notice that the variables are overriden
More complicated case:
set RANDOMTEMP_EXECUTABLE=nvcc
./randomtemp.exe -v -ccbin ^
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\cl.exe" ^
"test.cpp"
:: you may notice that the generated temp directories are used
export RANDOMTEMP_EXECUTABLE=nvcc
./randomtemp.exe -v -ccbin ^
"/usr/bin/gcc-5" ^
"test.cpp"
# you may notice that the generated temp directories are used
- RANDOMTEMP_EXECUTABLE: target executable to be patched (Optional, default: name of the current executable)
- RANDOMTEMP_BASEDIR: directory to store temporary files (Optional, default: current working directory)
- RANDOMTEMP_MAXTRIAL: max times for retry the command (Optional, default: 3)
Dependencies:
- Visual Studio 2017 / 2019 (Windows only)
- Clang / GCC (Linux only)
- Rust 1.42.0
You may run the following commands to build and test the project.
cargo build
# On Windows
set PATH=%PATH%;%CD%\target\build
# On Linux
export PATH="$PATH:$PWD/target/build"
cargo test
- If you don't specify
RANDOMTEMP_EXECUTABLE
, the target executable may not be found under some circumstances.