When you run a script, the shell creates a new sub-shell
. That's why it doesn't work. The PATH is updated in the sub-shell, but when the script finishes, that sub-shell and all of its settings (including environment variables) are lost. There is no way to "push" a sub-shell's settings into its parent.
You need to source
the file instead of running it. Source'ing a file acts as if you input each line in the file directly at the command prompt. You can source a file in one of two ways:
or the short-hand: