- This repository serves to help those who need to install
asdf
usingWSL2
and we will be installingruby
,nodejs
andyarn
usingasdf
- You may find the article about this repository at dev.to
Author: Michelle Loh
Update Date: 31/8/2021
Created Date: 29/8/2021
- What is WSL2
- What is asdf
- Install WSL2
- Before installing asdf
- Install asdf
- Add plugins
- Install language
- Install gems
- References
Read Microsoft WSL2 Documentation
Read asdf virtual manager Documentation
Video Reference: WSL 2: Getting started (Watch from Overview until PowerShell Commands (0:00 - 8.23))
- In your Ubuntu, type
code .
to open up Visual Studio Code (VS Code) - Open your terminal in VS Code
- In your terminal, it should be in already be Linux not Windows (You are in Windows if you have something like
PS C:\Users\>
), go to linux by typingwsl
$ PS C:\Users\>wsl
# Go to root directory
$ <user_name>: cd /
- Do this to get dependencies for wsl2 (else you might got error when installing ruby:
BUILD FAILED (Ubuntu 20.04 using ruby-build 20210804)
For more information related to solving this problem: read here
$ sudo apt-get update
$ sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline-dev zlib1g-dev libncurses-dev libffi-dev libgdbm-dev
- Follow the documentation
$ sudo apt install curl git
$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.1
- Add
. $HOME/.asdf/asdf.sh
and. $HOME/.asdf/completions/asdf.bash
in the end of.bashrc
file - Call
code ~/.bashrc
in your terminal
$ asdf plugin add ruby
$ asdf plugin add nodejs
$ asdf plugin add yarn
- Install ruby, nodejs and yarn latest version (or you can specify the version needed)
$ asdf install ruby latest
$ asdf install nodejs latest
$ asdf install yarn latest
- Check the version installed (the versions mentioned here is the latest version I downloaded)
$ asdf list
nodejs
16.8.0
ruby
3.0.2
yarn
1.22.11
- Add to your shell
$ asdf shell ruby 3.0.2
$ asdf shell nodejs 16.8.0
$ asdf shell yarn 1.22.11
- Add to global
$ asdf global ruby 3.0.2
$ asdf global nodejs 16.8.0
$ asdf global yarn 1.22.11
- Check where is languages installed
$ $ type -a ruby
ruby is /home/<user>/.asdf/shims/ruby
$ type -a node
node is /home/<user>/.asdf/shims/node
$ type -a yarn
yarn is /home/<user>/.asdf/shims/yarn
yarn is /mnt/c/Program Files (x86)/Yarn/bin/yarn
- Check whic ruby and gems your directory is referring to (in case you have more than ruby installed)
$ which ruby
/home/<user>/.asdf/shims/ruby
$ which gem
/home/<user>/.asdf/shims/gem
- If not in
.asdf/shims
, doasdf reshim ruby 3.0.2
(specify the version yourself, mine here is 3.0.2) - Install gems
$ gem install rails
- The rest can follow Installing Ruby on Rails Using asdf (starting 5:24)