# How to Install WSL for Windows 10 - Includes WSL2 Optional Steps

**URL:** <https://forum.openzeppelin.com/t/how-to-install-wsl-for-windows-10-includes-wsl2-optional-steps/2542>\
**Category:** Guides and Tutorials\
**Created:** [March 29, 2020, 3:23pm UTC](https://forum.openzeppelin.com/t/how-to-install-wsl-for-windows-10-includes-wsl2-optional-steps/2542 "2020-03-29T15:23:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jshanks21](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/jshanks21/32/1772_2.png) [@Jshanks21](https://forum.openzeppelin.com/u/Jshanks21)\
**Post date:** [March 29, 2020, 3:23pm UTC](https://forum.openzeppelin.com/t/how-to-install-wsl-for-windows-10-includes-wsl2-optional-steps/2542/1 "2020-03-29T15:23:26Z")

</div>

This walkthrough attempts to compile multiple sources and guides on how to install WSL (Windows Subsystem for Linux) to optimize for smart contract development.

Ideally, this will serve as a full guide for functional installation. In many cases, this will serve as just another resource to help optimize the installation for your specific needs.

All the information in this walkthrough can be found in other guides and resources online. They will be presented as used in relevant steps. They will also be listed at the bottom of the post in a Resources section.

**Important:** At the time of writing, WSL2 is available for use and claims to have superior performance. However, the [guide provided by Microsoft](https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2#install-windows-10-insider-preview-build) requires users to install Windows 10 Insider Preview Build for WSL2. Depending on your circumstance, this may or may not be ideal as it offers the newest releases, but, with them, potential bugs yet to be addressed. [This article from howtogeek](https://www.howtogeek.com/257948/should-you-use-the-windows-10-insider-previews/) can help you decide whether or not the Insider Preview Build is ideal for your needs.

We will start with the steps for installing WSL2. If you don’t want to be part of the Windows 10 Insider Preview Build, you can skip **step 1** and **optional step 4** to install the original WSL, instead of WSL2, without being a part of the Insider Preview Build.

**Step 1:** Install the Windows 10 Insider Preview Build

- Make sure your Windows is up to date. You can use the [Windows update assistant](https://www.microsoft.com/software-download/windows10) to do so.

 ![Step1-Update Windows](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/4/4cf4a885bc16da6ae80c9dd9871c9bde180611ab.png)

- Open the Start menu and click on Settings. Search for **Windows Insider Program**.

 ![step3-start-settings-WIP](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/d/dea03121cee73697d8579c18c3c46be3cab25e90.png)

- Click “Get Started”.

 ![step4-getStarted](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/f/f54775b0d06ee884064f212eb9e629960e7f73fd.png)

- Link and register your Microsoft account.

 ![step5-register](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/4/423abd85025a97248c86cd8cddbf0ab8f2e5ae0a.png)

- Choose the rate at which you’d like to receive insider preview updates. Fast will be prone to the most bugs with Release Preview being prone to the least. [This article](https://www.howtogeek.com/257948/should-you-use-the-windows-10-insider-previews/) may help you determine the best option for your needs.

 ![step6-insider settings](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/3/3680abafae6bce6d89672f31fa64aead66a7217a.png)

**Step 2:** [Enable Windows Subsystem for Linux and the Virtual Machine](https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2#enable-windows-subsystem-for-linux-and-virtual-machine-platform)

- Open the Start menu and click on Settings. In Settings, search for **Turn Windows features on or off**.

 ![step1-noWSL2-VMPlatformLinux](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/9/9419a38b01fdb476d5c037a84b9842ff8cb68097.png)

- You can also do this through the Powershell console if you prefer. The effects should be the same.

 ![step1a-noWSL2-powershellCmd](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/4/491ac7f6655307eea7bc27733e082a6ba9507292.png)

- Restart your computer.

**Step 3:** Install a Linux Distribution

- There are a few different ways to install and many Linux distribution variations to choose from. Installing [Ubuntu 18.04 LTS](https://www.microsoft.com/store/productId/9N9TNGVNDL3Q) through the Microsoft store is recommended by Microsoft [here](https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2#install-a-linux-distribution). However, additional installation means and distributions can be found [here](https://docs.microsoft.com/en-us/windows/wsl/install-win10?redirectedfrom=MSDN#install-your-linux-distribution-of-choice)

- We will continue with the Microsoft recommendation. Find Ubuntu 18.04 LTS on the Microsoft store [here](https://www.microsoft.com/store/productId/9N9TNGVNDL3Q), and click **Get**.

 ![step3-noWSL2-getUbuntu](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/b/ba92612d80a13332c40830ede6f25ba4469a9b91.png)

- After it’s downloaded, click **Launch**.

 ![step2.5-noWSL2-downloadUbuntu](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/b/b8e82efcaca253262a1477a057ec2e466cb6c08e.png) .

- The terminal below should appear. After a few minutes, you’ll be prompted to enter a username and password. These are totally unrelated to your Windows username and password, and are only requested upon the first installation. Additional guide on initialization found [here](https://docs.microsoft.com/en-us/windows/wsl/initialize-distro).

- **Note:** The username will be your default user profile for Linux. Also, you will be prompted to enter your password when using `sudo` commands, so something easy to remember and type is more convenient.

 ![step3-noWSL-launchUbuntu](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/d/d7d0d7ba179b8f61faa3139fceb16cfb62f44f96.png)

- Once accepted, you will have access to the terminal. As you might notice below, a preferred username is all lowercase and accepts no numbers. 😅

 ![step4-noWSL2-username&password](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/e/e4e17f8b2609cb158978263d8019c3e8d2bd7d0c.png)

- Update and upgrade your Ubuntu distribution with `sudo apt update && sudo apt upgrade`. Or enter these commands separately like below. When the upgrade command requests permission to use disk space, enter `y` to continue.

 ![step6-noWSL2-updatepacks](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/e/eca22a279d3f406cd064af97274781cf83f2d117.png)

 ![step6.5-noWSL2-upgrade](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/5/5c7aa17076a0ced6d4cf0f7b30ab55fd3eec5fd8.png)

**Recommended:** Navigating to your Windows projects from this terminal may not be obvious at first. [This video](https://youtu.be/Cvrqmq9A3tA) can guide you through the set up steps and how to navigate to your projects. It also gives advice for interacting with your Windows projects through your Linux-based terminal. Below is an example of navigating through directories.

 ![step5-noWSL2-linuxRootFiles](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/3/32f28c474b38477104b8af163efa20aa6f478a6e.png)

**Optional Step 4: Install WSL2:** For WSL2 installations, there are a couple additional steps and some minor configuration. These steps can be found [here](https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2#install-wsl-2).

**Step 4:** [Install nvm, node.js, and npm](https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2#install-nvm-nodejs-and-npm)

- If you already have node and npm installed before this step like I did, it’s [recommended in the Microsoft documentation](https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2#install-nvm-nodejs-and-npm) to uninstall first to prevent any unexpected or unwanted interactions with new installs through nvm. The resource provided by the Microsoft documentation to remove node.js from Windows can be found [here](https://docs.microsoft.com/en-us/windows/nodejs/setup-on-windows#install-nvm-windows-nodejs-and-npm).

- However, this resource may be out of date. Instead, I found the steps to uninstall node and npm at the bottom of [this article](https://kalliphant.com/nodejs-npm-windows-install/) clearer and still effective. You should also remove any system environment variables that point to node or npm.

- After node and npm are uninstalled, open the Ubuntu command line to install cURL with `sudo apt-get install curl`

- Then use cURL to install nvm with `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash`

**Note:** At the time of writing, the most recent version of nvm is v0.35.3, but you can find the most recent version in their GitHub repo [here](https://github.com/nvm-sh/nvm).Just replace `v0.35.2` in the above code with your desired version.

- **Optional:** At this point, I installed build essentials and python as these are required in many npm libraries. To do this, enter `sudo apt install build-essential python -y`

- Close and reopen the Ubuntu terminal for the install to take effect.

- You can verify the install with `command -v nvm` which should return `nvm`

- `nvm ls` will display currently installed versions of node, which should be N/A at this point.

- Next, install the latest stable LTS version of nodejs with `nvm install --lts`

- Another check with `nvm ls` should now display the latest stable releases as your default as seen below.

 ![step7-installNVM-node-npm](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/9/98a88d003123a224ca16b0955552f08d291bddf1.png)

- You can also check the versions of node and npm, along with their default paths with `node --version`, `npm --version`, `which node`, and `which npm` as seen below.

![step7.1-checkversion&paths](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/1/19b3f6e144a3dfbf406c8ae1dcc769fffbe5a797.png)

**Step 5:** Install Truffle and test your contracts

- Now just enter `npm install -g truffle` to install Truffle. Or, to also install the Ganache client enter `npm install -g truffle ganache-cli`

- You can test that Truffle was installed by following the steps at the end of [this article](https://davidburela.wordpress.com/2017/05/12/how-to-install-truffle-testrpc-on-ubuntu-or-windows-10-with-windows-subsystem-for-linux/).

- Alternatively, or additionally, you can enter one of your own projects and run `truffle compile` to make sure your contracts compile properly.

 ![step8-compileSuccess](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/6/66372acdef86ea2f708857094eac8382b6afd695.png)

**Resources:**

- Burela “[How to Install Truffle and TestRPC on Ubuntu or Windows 10 with WSL](https://davidburela.wordpress.com/2017/05/12/how-to-install-truffle-testrpc-on-ubuntu-or-windows-10-with-windows-subsystem-for-linux/)”

- Chris Hoffman “[Should You Use the Windows 10 Insider Previews](https://www.howtogeek.com/257948/should-you-use-the-windows-10-insider-previews/)”

- Kalliphant “[How to install/uninstall Node.js and npm on Microsoft Windows](https://kalliphant.com/nodejs-npm-windows-install/)”

- [Microsoft WSL2 documentation](https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2)

- [Microsoft WSL documentation](https://docs.microsoft.com/en-us/windows/wsl/install-win10?redirectedfrom=MSDN)

- Noygal [WSL Install Guide](https://gist.github.com/noygal/6b7b1796a92d70e24e35f94b53722219)

- [NVM Github Repository](https://github.com/nvm-sh/nvm)

- StackOverflow “[How to Completely Remove Node.js from Windows](https://stackoverflow.com/questions/20711240/how-to-completely-remove-node-js-from-windows)”

- Treehouse Installation Guides " [Installing Node.js® and NPM on Windows](https://treehouse.github.io/installation-guides/windows/node-windows.html)"

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [March 29, 2020, 10:49pm UTC](https://forum.openzeppelin.com/t/how-to-install-wsl-for-windows-10-includes-wsl2-optional-steps/2542/2 "2020-03-29T22:49:16Z")

</div>

Hi @Jshanks21,

Thanks for creating this guide 🙏

I had issues installing `nvm` as I had errors that it required `npm`, so assume this was the issue of already having node/npm installed. I installed node and then installed `nvm`.

WSL2 will be generally available in the next version of Windows 10 (2004) so hopefully not too far away:

> **[WSL2 will be generally available in Windows 10, version 2004 | Windows...](https://devblogs.microsoft.com/commandline/wsl2-will-be-generally-available-in-windows-10-version-2004/)**
>
> WSL2 will soon be officially available as part of Windows 10, version 2004! As we get ready for general availability, we want to share one additional change: updating how the Linux kernel inside of WSL2 is installed and serviced on your machine.

---

<div class="post-metadata">

**Author:** ![Jshanks21](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/jshanks21/32/1772_2.png) [@Jshanks21](https://forum.openzeppelin.com/u/Jshanks21)\
**Post date:** [March 30, 2020, 8:27pm UTC](https://forum.openzeppelin.com/t/how-to-install-wsl-for-windows-10-includes-wsl2-optional-steps/2542/3 "2020-03-30T20:27:08Z")

</div>

Hi @abcoathup,

No worries! Glad to do it.

All the sources I found suggested removing any trace of node/npm on your computer before installing nvm to avoid unexpected issues. This also includes removing any system variables with a path leading to node/npm files.

The error seems to suggest that something is expecting npm to handle the install instead of cURL. A leftover system variable pointing to npm is my first guess.

Were you running the install through the Linux terminal?

After fully uninstalling node/npm, you’d want to use the Linux terminal, Ubuntu in the case above, to install cURL with `sudo apt-get install curl`.

Then use cURL through the Linux terminal to install nvm with the command `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash`.

Once installed, close and reopen the terminal for effects to take place and you can use nvm to install nodejs (which should include npm) with `nvm install --lts`.

It can be a bit tedious initially, but so far I’ve noticed much smoother performance working with my projects than on Windows directly (shocking, I know). Looking forward to version 2004! I’m not used to manually updating my tools. 😅

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [March 31, 2020, 3:04am UTC](https://forum.openzeppelin.com/t/how-to-install-wsl-for-windows-10-includes-wsl2-optional-steps/2542/4 "2020-03-31T03:04:40Z")

</div>

> [@Jshanks21](#):
>
> Were you running the install through the Linux terminal?

Yes. I ran it via an Ubuntu terminal. I assume I still have `npm` in my path when I ran `curl`

* * *

I am finding WSL2 much faster than WSL. I had been going to wait for general release, but given that we are now close, decided to give it a go.

---

<div class="post-metadata">

**Author:** ![Jshanks21](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/jshanks21/32/1772_2.png) [@Jshanks21](https://forum.openzeppelin.com/u/Jshanks21)\
**Post date:** [March 31, 2020, 11:56pm UTC](https://forum.openzeppelin.com/t/how-to-install-wsl-for-windows-10-includes-wsl2-optional-steps/2542/5 "2020-03-31T23:56:38Z")

</div>

Glad to know there’s a noticeable difference. Have you noticed any buggy behavior with it? That’s the only reason I didn’t go with WSL2. I guess if it’s close to release any bugs should be limited though.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [April 1, 2020, 12:02am UTC](https://forum.openzeppelin.com/t/how-to-install-wsl-for-windows-10-includes-wsl2-optional-steps/2542/6 "2020-04-01T00:02:57Z")

</div>

No obvious bugs so far, though it is early days. I like the speed of WSL2.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [April 7, 2020, 2:05am UTC](https://forum.openzeppelin.com/t/how-to-install-wsl-for-windows-10-includes-wsl2-optional-steps/2542/7 "2020-04-07T02:05:52Z")

</div>

I store my git credentials in Windows Credential Manager.  
I previously created a GitHub Personal Access Token.

> **[Store git credentials in WSL (Windows Subsystem for Linux) – Liam Ederzeel](https://liamederzeel.com/store-git-credentials-in-wsl/)**
>
> This is a short guide for using wincred from Git for Windows in WSL (Windows Subsystem for Linux). All you have to do is add a view lines to you global .gitconfig Make sure you have installed Git for Windows Add the following to you...

---

<div class="post-metadata">

**Author:** ![Jshanks21](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/jshanks21/32/1772_2.png) [@Jshanks21](https://forum.openzeppelin.com/u/Jshanks21)\
**Post date:** [April 7, 2020, 5:07pm UTC](https://forum.openzeppelin.com/t/how-to-install-wsl-for-windows-10-includes-wsl2-optional-steps/2542/8 "2020-04-07T17:07:10Z")

</div>

Seems easy to implement. But I’ve been using VSCode and I’m able to commit and push all changes within the editor. What are the benefits of storing git credentials in WSL if I’ve grown accustomed to doing it this way?

Btw, I am familiar with using git bash, or other terminals, to stage, commit, and push changes, so I do understand how to do this traditionally. But VSC has just proven to be too convenient not to use more often for my own projects.
