Skip to content

This repository serves to help those who need to install asdf using WSL2 and we will be installing ruby, nodejs and yarn using asdf

License

Notifications You must be signed in to change notification settings

Michelle-Lohwt/asdf-install-wsl2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Install asdf (ruby, nodejs and yarn) in WSL2

  • This repository serves to help those who need to install asdf using WSL2 and we will be installing ruby, nodejs and yarn using asdf
  • You may find the article about this repository at dev.to

Author: Michelle Loh
Update Date: 31/8/2021
Created Date: 29/8/2021


Table of Contents

  1. What is WSL2
  2. What is asdf
  3. Install WSL2
  4. Before installing asdf
  5. Install asdf
  6. Add plugins
  7. Install language
  8. Install gems
  9. References

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

  1. In your Ubuntu, type code . to open up Visual Studio Code (VS Code)
  2. Open your terminal in VS Code
  3. 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 typing wsl
$ PS C:\Users\>wsl

# Go to root directory
$ <user_name>: cd /
  1. 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

Install asdf

  1. Follow the documentation
$ sudo apt install curl git
$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.1
  1. Add . $HOME/.asdf/asdf.sh and . $HOME/.asdf/completions/asdf.bash in the end of .bashrc file
  2. Call code ~/.bashrc in your terminal

Add plugins

$ asdf plugin add ruby
$ asdf plugin add nodejs
$ asdf plugin add yarn

Install language

  1. 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
  1. 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
  1. Add to your shell
$ asdf shell ruby 3.0.2
$ asdf shell nodejs 16.8.0
$ asdf shell yarn 1.22.11
  1. Add to global
$ asdf global ruby 3.0.2
$ asdf global nodejs 16.8.0
$ asdf global yarn 1.22.11

Install gems

  1. 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
  1. 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
  1. If not in .asdf/shims, do asdf reshim ruby 3.0.2 (specify the version yourself, mine here is 3.0.2)
  2. Install gems
$ gem install rails
  1. The rest can follow Installing Ruby on Rails Using asdf (starting 5:24)

References

  1. Microsoft WSL2 Documentation
  2. asdf virtual manager Documentation
  3. WSL 2: Getting started
  4. BUILD FAILED (Ubuntu 20.04 using ruby-build 20210804)
  5. Installing asdf and using it to install Go, Python & Terraform
  6. Installing Ruby on Rails Using asdf

About

This repository serves to help those who need to install asdf using WSL2 and we will be installing ruby, nodejs and yarn using asdf

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published