简体   繁体   中英

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

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.

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"

After some more playing around "$PATH" did the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM