📜  ruby install - Shell-Bash (1)

📅  最后修改于: 2023-12-03 14:47:08.465000             🧑  作者: Mango

Ruby Install - Shell-Bash

Ruby is a popular programming language used for web development, data analysis, and automation. Before you can start coding with Ruby, you need to install it on your machine. In this guide, we'll walk you through the steps to install Ruby on your system using Shell-Bash.

Prerequisites

Before installing Ruby, you need to make sure that your system has the required dependencies installed. This includes:

  • GCC compiler
  • GNU Make
  • zlib and its headers
  • OpenSSL and its headers
  • readline and its headers
  • Git

To install these dependencies on a Ubuntu system, run the following command:

sudo apt update
sudo apt install -y build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev git

For other Linux distributions, refer to their package manager documentation.

Ruby Installation

Once the dependencies are installed, you can proceed with the Ruby installation process.

  1. Open your terminal and run the following command to download the latest stable version of Ruby:
wget https://cache.ruby-lang.org/pub/ruby/$(echo "$(curl -sSL https://www.ruby-lang.org/en/downloads/ | grep 'ruby-\d' | tail -n 1 | cut -d '"' -f 2 | cut -d '/' -f 4)"/$(curl -sSL https://www.ruby-lang.org/en/downloads/ | grep 'ruby-\d' | tail -n 1 | cut -d '"' -f 2)) && \
tar -zxvf ruby-* && \
cd ruby-* && \
./configure && \
make && \
sudo make install

This command will download the latest stable version of Ruby, extract it, configure it, and then build and install it on your system.

  1. Verify that Ruby is installed by running the following command:
ruby -v

This will output the version of Ruby installed on your system.

Conclusion

Congratulations! You have successfully installed Ruby on your system using Shell-Bash. You're now ready to start coding with Ruby and build amazing applications. Happy coding!