Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

.envtc and the TEMP environment variable

Aug
1,943
71
With DIRENV on,
I have an .envtc file stored on my RAMDisk,
which is drive R:\

The DIRENV and .envtc were introduced in Version 30.

The contents of the .envtc file on my R:\ drive;
Code:
R:\>type .envtc
temp=r:\temp

On a drive other than R:\, my TEMP environment variable points to;
Code:
TEMP=C:\Users\jlcav\AppData\Local\Temp

When I switch to drive R:\, the TEMP environment variable becomes;
Code:
R:\>set temp
r:\temp

When I switch to a drive other than R:\, the TEMP environment variable becomes;
Code:
E:\Utils>set temp
TCC: Not in environment "temp*"

My workaround to this issue,
is to use SETLOCAL before switching to my R:\ drive.
Code:
E:\Utils>set temp 
C:\Users\jlcav\AppData\Local\Temp

E:\Utils>setlocal 

E:\Utils>set temp 
C:\Users\jlcav\AppData\Local\Temp

E:\Utils>r: 

R:\>set temp 
r:\temp

R:\>e: 

E:\Utils>set temp 
TCC: Not in environment "temp*"

E:\Utils>endlocal 

E:\Utils>set temp
C:\Users\jlcav\AppData\Local\Temp

Posting this mainly for my future reference,
but thought others might find it useful.

Joe
 
When I switch to a drive other than R:\, the TEMP environment variable becomes;
Code:
E:\Utils>set temp
TCC: Not in environment "temp*"
Don't you think TCC should reset it to the default? [Suggestions?]
 
No, I think it is okay.

I think that the documentation should be updated
to include what happens to an environment variable,
once it goes out of scope,
due to an .envtc file.

That is,
the environment variable gets deleted from the environment.

Documentation should include the work-around with SETLOCAL/ENDLOCAL.

Joe
 
Back
Top