Zend certified PHP/Magento developer

Appending File Path (With Spaces) to $PATH Variable Removes the Spaces

I have the following command in my .profile file: PATH=$PATH:"/mnt/c/Users/spenpal/AppData/Local/Programs/Microsoft VS Code/bin/".

When I start up my terminal and try echo $PATH, I get the following output:

> echo $PATH
[*other paths*]:/mnt/c/Users/spenpal/AppData/Local/Programs/MicrosoftVSCode/bin/

The spaces were removed from the file path when it was added to the $PATH variable.

However, if I run the same command manually in my terminal and print out the paths, I get this:

> PATH=$PATH:"/mnt/c/Users/spenpal/AppData/Local/Programs/Microsoft VS Code/bin/"
> echo $PATH
[*other paths*]:/mnt/c/Users/spenpal/AppData/Local/Programs/Microsoft VS Code/bin/

Why does it work when I do it manually vs. when I have it in my .profile file? And how do I prevent this from happening (as I don’t want to export this path manually every time I load up the terminal)?

System Specs:

  • OS: WSL2
  • Distro: Ubuntu 22.04.3 LTS