Saturday, April 27, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1369  / 1 Year ago, thu, february 23, 2023, 4:08:09

I am using windows-subsystem-for-Linux, and I choose Ubuntu. But I can't call the program installed on the Windows OS, so I check the environment variable list in WSL, it seems that the spaces are replaced with colons when transporting the environment variables into WSL.

Considering that in WSL, the environment variables list is a colon-delimited list. In Win32, it is a semicolon-delimited list.

I think this the reason why I can't call the program installed on the windows OS. So I checked another laptop, this phenomenon doesn't exist and everything works fine.


My question is:



  1. Why does this problem happen?

  2. How could I fix it?


enter image description here


enter image description here



 Answers
6

I think you have several problems in here.



  1. Executing a windows binary program from a WSL Linux Shell.
    You're executing Windows, so why don't you run your program from Windows CMD, a .BAT file, or Powershell?.


In any case, make sure that you have enabled this in /etc/wsl.conf


[interop]
enabled=True

Please note: This option is available in Insider Build 17713 and later.



  1. Why the problem with the path, transforming spaces to : ?
    I don't know. In Linux spaces in the path are represented by:


 

(bar and a space, inside quotes, or space if not using quotes)


So I think you need to replace your PATH by what you have by replacing:
d/ProgramFiles/VS_Code/Microsoft:VS:Code/bin
by:
d/ProgramFiles/VS_Code/Microsoft VS Code/bin


Please check:
/etc/wsl.conf


You should have:


[interop]
appendWindowsPath=True

Please, check options in [automount] section.
https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-per-distro-launch-settings-with-wslconf


If you need to patch your PATH every time you can do a script like fixpath.sh:


#!/usr/bin/env bash
PATH=$(echo "$PATH" | sed "s/Microsoft:VS:Code/Microsoft VS Code/")
export PATH

Then you run:


source ./fixpath.sh

Cheers


[#2117] Friday, February 24, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
inglehare

Total Points: 330
Total Questions: 111
Total Answers: 95

Location: Sint Maarten
Member since Tue, Mar 29, 2022
2 Years ago
;