docs/windows_cheatsheet.md
Hello and welcome to this Windows cheatsheet.
The goal is to gather here all known issues and tips with the Windows setup.
When trying to connect to remote hosts, eg. when trying to do sudo apt update, you might see an error message saying that the network is unreachable. Here are two possible solutions: if the first one doesn't help, try the second one.
Start > cmd > 'Open as administrator'wsl --shutdown
netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns
Start > Search for Network Reset; click Reset)sudo mv /etc/resolv.conf /etc/resolv.conf.old
sudo touch /etc/resolv.conf
sudo echo "[network]\ngenerateResolvConf = false\n" >> /etc/wsl.conf
wsl.exe --shutdown
When running wsl --set-default-version 2, you might get a:
Error: 0xc03a001a The requested operation could not be completed due to a virtual disk system limitation. Virtual hard disk files must be uncompressed and unencrypted and must not be sparse.
To fix this issue, open the File Explorer and go to:
C:\Users\<YOUR_USERNAME>\AppData\Local\Packages\CanonicalGroupLimited<SOMETHING>
It should look something like this:
Right click on LocalState, then Properties, then Advanced.
Ensure Compress contents to save disk space and Encrypt contents to secure data are both deselected.
Click OK, then Apply, then Apply changes to this folder only.
This happens when the hidden wslhost.exe is not working. We just need to restart it!
Close all WSL2 tabs.
Open a PowerShell tab and run the following command:
wsl.exe --shutdown
Check that your Ubuntu is properly stopped with the command
wsl -l -v
Open a new WSL2 Tab, problem should be fixed.
If you get this error trying to connect to your rails server, serve or jupyter notebook, a simple restart of WSL might do the trick.
wsl --shutdown to shutdown WSL.wsl to restart WSL.localhost:xxxx. You can as well try 127.0.0.1:xxxx (the local IP of the machine) instead.If the issue is still present, you need to allow the connection in Windows Defender Public rules. Close all WSL terminal. Open a PowerShell terminal and type the following command to stop all WSL processes:
wsl --shutdown Ubuntu
Hit Start and type Windows Defender Firewall and open it.
Click on Advanced Settings
Right click on Inboud Rules and select New Rule.... Under Rule Type leave Program selected and hit Next.
For the program, Select The program path: and paste this path: %SystemRoot%\System32\wsl.exe. Click on Next.
For the Action section, make sure Allow the connection is selected and hit Next.
For the Profile section, make sure the 3 options are selected and click on Next.
Finally you will be asked to chose a name for this new rule, go with WSL - Inbound.
Repeat the whole process by creating a Outbound Rule with the same settings, except for the name: WSL - Outbound.
The warning Insecure world writable dir /mnt/c in PATH, mode 040777 is caused by the two differents way of Windows & Linux to deal with file permissions.
To silence those warnings:
sudo touch /etc/wsl.conf
echo '[automount]' | sudo tee -a /etc/wsl.conf > /dev/null
echo 'options="metadata,umask=0033"' | sudo tee -a /etc/wsl.conf > /dev/null
Restart all terminals.
Microsoft is slowly releasing the latest major version of Windows (version 2004). Here is the guideline if your Windows is not offering you the update.
Go to Windows 10 and under Windows 10 May 2020 Update click on Update now. This will download a tool on your machine. Open it.
A compatibility check will start:
Next, you will be offered a choice, choose Upgrade this PC now and click on Next:
Let the tool do the work:
Microsoft is encountering some errors with the version 2004, Chances are that the update assistant will tell you that you're machine is not compatible yet!
Do not close the assistant.
Open a file explorer at this path C:\$WINDOWS.~BT\Sources\Panther
Locate the file compatscancache.dat and delete it
Go back to the update assistant and click Refresh.
The installation should carry on.
This happens if you're using AVG antivirus. Disable AVG VPN if you're using it.
Open AVG Internet Security -> Menu - Settings - Full Protection - Enhanced firewall. Check Enable Internet connection sharing mode
On the same page, click on System Rules and enabled the first 2 options Windows file & printer sharing Remote desktop connections
Scroll down to click on save.
If you experience slow network on your fresh WSL2:
Open Ubuntu (or your other distro)
Open Network Connections in your settings ("View network connections" in your windows search)
You should see
vEthernet (WSL)
Enabled
Hyper-V Virtual Ethernet Adapter
Right-click and open Properties
In the Properties pane, click Configure...
In the Configure pane, go to the "Advanced" Tab
Click on "Large Send Offload Version 2" and update the value to "Disabled"
If you see two "Large Send Offload Version" options, disable both.
If you see issues connecting to your Cloudinary API from your local WSL and you saw this error.
Stale request - reported time is 2016-12-15 04:14:53 +0000 which is more than 1 hour ago
The error is caused by a different system time between the WSL OS and the windows host machine. To fix it, please run this command in your windows terminal:
sudo hwclock -s
Type your WSL password and click enter.
If the GitHub CLI installation instructions fail, chances are that you have the package gitsome installed. This package provides a gh binary which can conflict with gh GitHub CLI binary. In this case, run sudo apt remove gitsome before running the GitHub CLI installation instructions again.
Open a PowerShell terminal.
Type the following command:
wsl -l -v
It will tell you the name of your WSL, it's state and version.
To switch a WSL from version 1 to 2, open a PowerShell terminal.
Type the following command: ⚠️ The conversion's time depends on the size of your Ubuntu filesystem, it can be long and WSL will be unsuable in the meantime. ⚠️
wsl --set-version Ubuntu 2
You can revert to version 1:
wsl --set-version Ubuntu 1
To access the root session, open a PowerShell terminal.
Type the following command:
wsl -d Ubuntu -u root
You can change the password of that root session by using the command:
passwd
You will prompted to enter a new password.
Now, from your normal session, you can switch from your session to the root on with:
su -
You will be asked for the password.
You can exit the root session with Ctrl + D.
You need to have the latest version of Chrome installed on your machine to run tests on Rails, since we will use Headless Chrome for System Testing. It's a browser without a user interface, well-suited for this kind of automated tests. Before running your system tests you need to make sure you have a recent version of Chrome on your system (not Chromium).
If you are getting a Webdrivers::BrowserNotFound: Failed to find Chrome binary error when running tests, it means that you are missing Chrome on your system or need to install the latest version:
# Ubuntu
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
rm -rf google-chrome-stable_current_amd64.deb
Once installed, you can run your tests with:
rails test:system