Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell cannot cd to a path name with $

In Windows Powershell, a command line cd $HOME leads to the Home directory. But a command line cd $TEMP or cd $GOPATH doesn't work, which returns cd : Cannot process argument because the value of argument "path" is null.

PS: The environment variables are configured.

Name                           Value
----                           -----
GOPATH                         C:\Gowork
GOROOT                         C:\Program Files\Go\
TEMP                           C:\Users\myusername~1\AppData\Local\Temp
windir                         C:\Windows
like image 931
TristeShine Avatar asked May 08 '26 20:05

TristeShine


1 Answers

If you meant the environment variable "temp", then you should do it as:

cd $env:temp

I think $HOME is some PowersShell specific variable, like $host, $ErrorActionPreference etc, while TEMP is a environment variable. Environment variables are read out as $env:VARIABLENAME.

I think gopath is also an environment variable of yours.

like image 74
ThomasMX Avatar answered May 10 '26 12:05

ThomasMX



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!