Windows Subsystem for Linux (WSL) – Setup and Troubleshooting

The Windows 10 anniversary update added some new features to Windows 10, including the much anticipated (maybe just by me) Windows Subsystem for Linux, or as all of the announcement articles said, “BASH for Windows”.

This is how to get rolling with WSL and how to troubleshoot the two most common problems.

Setup

Once you get the update, you still need to enable the feature. You can do this by opening PowerShell as an admin and typing

Get-WindowsOptionalFeature -Online -FeatureName * | ? {$_.FeatureName -like "*subsystem*"}

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

installing wsl

You will need to restart.

After the restart, go ahead and open up PowerShell as an admin — but make sure it’s not PowerShell(x86).

Since bash.exe is placed into System32, it will already be in your path. Go ahead and type ‘bash’

If developer mode is not enabled, you will see the following:

dev_mode needed

You can enable Developer Mode by issuing

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"

Once you agree to the terms, the download will begin.

dev_mode

When it gets to the point where it’s extracting the file system, it actually does take awhile. Nothing is wrong.

Follow the remaining prompts to setup your account and you should be ready to go!

etc

Troubleshooting

There are a couple of issues that you may run into when settings this up.

Path prioritization
There’s a chance that you have other items in your path that contain a bash binary. An example would be Cygwin. Remember, your path just a bunch of ordered strings. It does search them in order — meaning if Cygwin is higher in your path than System32, ‘bash’ will reference that binary instead.

If you type ‘bash’ and all the sudden you see that you are in Cygwin, I suggest checking your path. You can do that with PowerShell like so

$Reg = "Registry::HKLM\System\CurrentControlSet\Control\Session Manager\Environment"

(Get-ItemProperty -Path "$Reg" -Name PATH).Path

 

Or navigating the GUI

env_gui

Moving Cygwin below System32 will resolve the issue.

PowerShell(x86)
You launch PowerShell(x86), and it doesn’t recognize the term ‘bash’. You checked your path and it’s there. You open up File Explorer, and you see bash.exe chilling there.

syswheres

search sxs

You cd into System32, and you don’t see bash.exe….even though you just saw it in File Explorer. What gives?

PowerShell(x86) is lying to you. You are not in System32, you are in SysWOW64. Yes, typing ‘pwd’ says otherwise, but it’s all a big lie.

When WSL was enabled, bash.exe was placed in System32, but NOT in syswow64. That’s why PowerShell(x86) can’t see it.

The solution to this is pretty straight forward: Use ‘Windows PowerShell’, not ‘Windows PowerShell (x86)’

powershells

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s