Home > Backend Development > C#.Net Tutorial > How to install Ruby on Linux

How to install Ruby on Linux

藏色散人
Release: 2019-01-24 15:12:53
Original
4843 people have browsed it

Ruby is installed by default on most Linux distributions. However, you can follow the steps below to determine if Ruby is installed and, if not, install a Ruby interpreter on your Linux machine.

How to install Ruby on Linux

#How to install Ruby on Linux?

For Ubuntu-based distributions, follow the procedure below to verify that Ruby is installed, and if not, install it.

1. Open a terminal window. One way to open a terminal window (sometimes called a "shell" or "bash shell") is to select Applications > Accessories > Terminal.

2. Run the ruby ​​command. If you see a path like /usr/bin/ruby, Ruby is installed. If you don't see any response or receive an error message, Ruby will not be installed.

3. To verify that you have the current version of Ruby, run the command ruby ​​-v.

4. Compare the returned version number with the version number on the Ruby download page.

These numbers are not necessarily exact, but if you are running an older version, some features may not work properly.

5. Install the appropriate Ruby package. The process varies between distros, but on Ubuntu run the following command:

sudo apt-get install ruby-full
Copy after login

Verify that Ruby is working

Open a text editor and save the following as test.rb.

#!/usr/bin/env ruby
puts "Hello world!"
Copy after login

In the terminal window, change directory to the directory where test.rb is saved. Run the command chmod x test.rb and then run the command ./test.rb.

You should see the message Hello world! If Ruby is installed correctly,

prompt is displayed:

1. Every distribution is different. For help installing Ruby on distributions other than Ubuntu or its variants, see your distribution's documentation and community forums.

2. For distributions other than Ubuntu, if your distribution does not provide a tool like apt-get, then you can use sites such as RPMFind to find Ruby packages. Look for the irb, ri and rdoc packages, but depending on how the RPM package is built, it may already contain these programs.

The above is the detailed content of How to install Ruby on Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template