What is WSL2
Read Microsoft WSL2 Documentation
What is asdf
Read asdf virtual manager Documentation
Install WSL2
Video Reference: WSL 2: Getting started (Watch from Overview until PowerShell Commands (0:00 - 8.23))
Before installing asdf
- 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 the following to get dependencies for wsl2 (else you might get the error when install 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
Install asdf
- Follow the documentation of in asdf virtual manager 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
Close and refresh terminal
- Close your terminal by clicking the rubbish bin icon
- Reopen the terminal
Add plugins
$ asdf plugin add ruby
$ asdf plugin add nodejs
$ asdf plugin add yarn
Install language
- 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
Install gems
- 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 which ruby and gems your directory is referring to (in case you have more than 1 ruby version 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)
Top comments (2)
Very good article thank you
Welcome