PowerShell on OS X: Setting Your Path Variable


There are two tricky little problems when setting your path variable in PowerShell. Here’s how to get past them.

First, lots of guides show things like this:

$Env:Path += "PATH_STRING"

Which works on Windows but won’t work on OS X. The variable name has to be all-caps:


Next, the separator between path elements on Windows is ;, but on OS X it’s :. Swap them and you should be good to go:

# Windows-only, won't work:
# $Env:PATH += ";/Users/adam/opt/bin"

# Works on OS X:
$Env:PATH += ":/Users/adam/opt/bin"

Small details, but they were remarkably fiddly to figure out the first time I ran in to them. Lots of people use Posh on Windows, so lots of guides and docs won’t work on Mac. You may find similar compatibility problems in scripts, too. Hopefully this saves you from some frustration.

Happy scripting,


Need more than just this article? I’m available to consult.

You might also want to check out these related articles: