Custom Path in PATH Variable is Not Working on Mac
Asked Answered
O

1

1

What I am trying to achieve

I added a custom location in the PATH variable hoping that I could run shell scripts placed in that location easily. But it is not working as I expected.

Here is what echo $PATH returns

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/code/lab/pathcommands:/usr/local/go/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands

I have placed my script file named pause in $HOME/code/lab/pathcommands path. I was hoping I could just run pause from the terminal and it would run the script file. But it returns zsh: command not found: pause

If I place the same script file in /usr/local/bin (which is also a part of $PATH variable), it works as expected.

What am I missing?

My OS - macOS Big Sur

Terminal - iTerm2

Oleneolenka answered 28/10, 2021 at 0:59 Comment(3)
If echo $PATH returns the characters $HOME and not the value of $HOME, then you've defined your path incorrectly. Show us how you modified your PATH.Boogeyman
@glennjackman I added $HOME/code/lab/pathcommands at the end of /etc/paths file.Oleneolenka
When I replaced $HOME with actual value. It started working. Thank you @glennjackman.Oleneolenka
S
0

Really strange issue, after one year of using maven like:

export someDir=direct/path/without/other/variables    
export PATH=$PATH:$someDir/maven/bin

the system suddenly stopped recognising 'mvn any' command with the message:

zsh: command not found: mvn

But when I changed my ~/.zprofile so the PATH variable looked like:

export PATH=$PATH:direct/path/without/other/variables/maven/bin

Everything proceeded to work as expected.

Strachan answered 14/2, 2023 at 18:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.