Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WSL (windows subsystem linux) breaks $PATH when the windows PATH has folder names with spaces

When I start WSL I cant add folders to path. I found out that this is because folders that are included in the windows PATH that has white spaces in their name break the linux $PATH. : For instance, when putting $PATH in the command line I am getting ....Some other folders...:/mnt/c/Program: no such file or directory.

If this was a manual process, I would use either "Program Files" of Program\ files but this is imported before ~/.bashrc kicks in so I dont know how to fix this.

Thank you for helping

like image 949
yair suari Avatar asked Jun 17 '20 13:06

yair suari


2 Answers

I ran into the same problem when I created a second instance of Ubuntu 20.04 and set the default user through /etc/wsl.conf. Quoting $PATH in Line 6 ( export PATH=$PATH:${snap_bin_path} ) in /etc/profile.d/apps-bin-path.sh solved the problem for me.

like image 108
pnanadikar Avatar answered Oct 06 '22 01:10

pnanadikar


Folders with spaces in their names should be enclosed with "", '', or escaped with backslash.

This is my path in .bashrc which I added in WSL to be able to use the code . to start up VSCode from WSL.

export PATH=$PATH:"/mnt/c/Users/Kamal/AppData/Local/Programs/Microsoft VS Code/bin"
like image 34
Kamal Hakim Avatar answered Oct 06 '22 00:10

Kamal Hakim