Ticker

6/recent/ticker-posts

Header Ads Widget

Responsive Advertisement

How to install ruby 3.4.3 in wsl ubuntu?

How to install ruby 3.4.3 in wsl ubuntu?


    How to install ruby 3.4.3 in wsl ubuntu?

    To install Ruby in Windows Subsystem for Linux (WSL), the recommended method is to use a version manager like rbenv.  This allows you to easily switch between different Ruby versions for various projects. 
    Step-by-Step Installation with rbenv
    Open your WSL terminal (e.g., Ubuntu) and follow these steps:
    1. Update your package list and install necessary dependencies:
      bash
      sudo apt update && sudo apt install -y build-essential libssl-dev libreadline-dev zlib1g-dev libffi-dev libyaml-dev git-core curl
      
    2. Install rbenv by cloning the repository from GitHub and adding it to your shell's PATH:
      bash
      git clone https://github.com/rbenv/rbenv.git ~/.rbenv
      echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
      echo 'eval "$(rbenv init -)"' >> ~/.bashrc
      
      • Note: If you are using a different shell like Zsh, replace ~/.bashrc with ~/.zshrc.
    3. Install the ruby-build plugin, which provides the rbenv install command:
      bash
      git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
      
    4. Restart your terminal by closing the current window and opening a new one to ensure the changes to your shell take effect.
    5. Install Ruby:
      • List all available Ruby versions using rbenv install -l.
      • Install the desired version (e.g., 3.3.4, a recent stable version):
        bash
        rbenv install 3.3.4
        
    6. Set the global Ruby version to the one you just installed:
      bash
      rbenv global 3.3.4
      
    7. Verify the installation by checking the Ruby version:
      bash
      ruby -v
      
      You should see the installed version, e.g., ruby 3.3.4 (2024-08-09 revision e51014f9c0) [x86_64-linux].
    8. (Optional) Install Bundler, a crucial gem for managing project dependencies:
      bash
      gem install bundler
      rbenv rehash

    Post a Comment

    0 Comments