0

At my new Organization,

I have a new MacBook Pro. (Ventura 13.x.x) when I try to set the path using PATH command

in Zshell

Commands I ran

export PATH=$PATH:/Users/xxx/xxx/Drivers/apache-maven-3.9.3/bin

source ~/ .zshrc

export -f

echo $PATH

Now I can see path got updated after above.

Later When I close the terminal and relaunch it PATH is not updated with the change I made

I tried Restarting my Mac couple of times, did the same work too many times.

I do have permissions on my Mac

-rw-r--r-- 1 xxxx staff 349 Jun 29 17:35 .zshrc

I am not sure When I open my paths file, maven is pointed there,

But still no luck. Please help me out with your tips and tricks.

jnpdx
  • 45,847
  • 6
  • 64
  • 94
Mahesh kumar
  • 119
  • 1
  • 7
  • What changes you made and to what file? – svlasov Jul 03 '23 at 16:16
  • I have made the changes to PATHS file in /etc/paths – Mahesh kumar Jul 03 '23 at 16:18
  • How you updated it? Maybe you made a typo? You do not give enough details. – svlasov Jul 03 '23 at 16:33
  • I have downloaded the maven zip and unzipped it Then I copied the bin path Then I opened the terminal ran the above commands in the sequence I specified, When I run echo $path command I can see the path got appended. Tested mvn from the same terminal. Later I closed again I launched the terminal but now terminal says Command not found: "zsh: command not found: mvn" to make sure I have opened the PATHS file in text editor, I can see it got appended. but still when I run echo $PATH in new terminal, it does not show the maven path in terminal. Please lMK if you need more info – Mahesh kumar Jul 03 '23 at 16:42
  • When you say "PATHS file", do you mean the actual `/etc/paths` file? Did you remember to save it after editing? – svlasov Jul 03 '23 at 17:25
  • Environment variables are passed from parent to child process only. Not to parents or siblings. The behaviour is expected. – Ulrich Eckhardt Jul 03 '23 at 18:16
  • @svlasov Yes I did save it back. – Mahesh kumar Jul 03 '23 at 18:21
  • @ulrich-eckhardt How do I resolve this now, also can you be little more detailed if possible? – Mahesh kumar Jul 03 '23 at 18:22
  • @Maheshkumar I think you're very confused about what things control what when it comes to your `PATH`. Running `source ~/.zshrc` doesn't save changes in your current shell into the permanent ~/.zshrc file, it does pretty much the reverse: it applies the settings in ~/.zshrc to your current shell. If you want to make a change that'll affect future shells, you need to edit ~/.zshrc *and then use `source ~/.zshrc` to apply that change to the current shell*. – Gordon Davisson Jul 03 '23 at 20:02
  • @gordon-davisson Thanks this has worked. Really great help. I will make this as an answer. – Mahesh kumar Jul 03 '23 at 20:34
  • Does this answer your question? [How to permanently set $PATH on Linux/Unix](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix) – Constantin Hong Jul 03 '23 at 20:49
  • I recommend against manually changing /etc/paths. In particular don't put directories below `/Users` there. – user1934428 Jul 05 '23 at 09:05

1 Answers1

0

I think you're very confused about what things control what when it comes to your PATH. Running source ~/.zshrc doesn't save changes in your current shell into the permanent ~/.zshrc file, it does pretty much the reverse: it applies the settings in ~/.zshrc to your current shell. If you want to make a change that'll affect future shells, you need to edit ~/.zshrc and then use source ~/.zshrc to apply that change to the current shell. –

#Gordon Davisson Thanks for your answer.

Mahesh kumar
  • 119
  • 1
  • 7