Now that you have your fancy WSL up and running, you want to use it and all your environment variables are NOT available (of course).
Luckily there is a workaround, using the WSLENV variable. Unfortunately, it is not a direct 1:1 translation of your existing variables, rather you will need to craft them manually and convert between the two environments before you run a command or switch environment.
For example, to pass your JAVA_HOME correctly to wsl:
set JAVA_HOME=%JAVA_HOME%
set WSLENV=JAVA_HOME/up
wsl
echo $JAVA_HOME
And the magic is behind that last /up flag which says: set the value when invoking WSL from Windows (u) and translate between Windows and Unix paths (p)
WARNING: spaces are NOT escaped
WARNING2: only ONE variable is shared, so you cannot share both JAVA_HOME and PATH for example at the same time
Showing posts with label WSL. Show all posts
Showing posts with label WSL. Show all posts
21/04/2020
[Windows] Activate and configure Windows Subsystem for Linux
Windows 10 introduced an update that adds a very cool feature: Windows Subsystem for Linux. If you are a fan of Cygwin, or similar tools, you will greatly like this feature as well.
Setup could be a bit more straightforward, but still not a big issue:
Setup could be a bit more straightforward, but still not a big issue:
- Enable Windows Subsystem for Linux as a Windows feature from Control Panel > Programs and Features > Turn Windows features on or off
- Reboot
- Make sure LxssManager service is running
- Install a Linux distro from Windows store, search for "WSL" and pick the one you prefer, for example Alpine or Ubuntu, if no distro is installed, you get an error instead:
Windows Subsystem for Linux has no installed distributions. Distributions can be installed by visiting the Windows Store: https://aka.ms/wslstore Press any key to continue...
And going to that link brings you nowhere.. so just install it yourself from the store.
After the installation is completed (might ask you to setup a user and password), you can open any command prompt and type wsl to launch it.
Be careful, that command was different in the past: lxrun or bash and there are apparently 2 versions of WSL as well, use whatever makes it run for you
Subscribe to:
Comments (Atom)