How to Install Ruby on Ubuntu 22.10

Ruby is an object-oriented interpreted programming language created by Yukihiro Matsumoto. This open-source language has many utilization situations, similar to creating net purposes and information evaluation.

Ruby is cherished for its easy syntax, which makes it appear to be builders are coding in English.

However, Ubuntu, a Linux distribution primarily based on Debian, is without doubt one of the most well-known free and open-source working techniques. Ubuntu’s ease of use has made it common with builders. If Ubuntu just isn’t put in in your PC, you possibly can obtain it from the official web site.

Putting in Ruby on Ubuntu 22.10 is your first step in the direction of creating completely different options utilizing this highly effective language.

This text discusses the three completely different approaches to putting in the Ruby improvement atmosphere in Ubuntu 22.10.

Set up Ruby utilizing the Ubuntu 22.10 repository

This method makes use of the built-in apt package deal supervisor to put in Ruby on Ubuntu 22.10. You’ll be able to obtain this by following these steps;

Step 1: Replace packages

Step one is to replace the system packages in your Ubuntu working system. Open your terminal and use the next command;

sudo apt replace

Step 2: Improve the system

This step upgrades your complete system. Use this command;

sudo apt improve

Step 3: Set up Ruby

You are actually prepared to put in Ruby. Use this command;

sudo apt set up ruby-full

After the set up course of is over, you possibly can verify which Ruby model is put in with this command;

ruby -v

You’ll get an identical output to this;

image-103

That is the simplest strategy to set up Ruby on Ubuntu 22.10. Nevertheless, this method has its drawbacks.

  1. You is probably not putting in the most recent Ruby model: This method installs the Ruby model within the Ubuntu package deal repositories, which is probably not the most recent Ruby model.
  2. Doesn’t set up a number of Ruby variations: Ruby works with completely different gems (libraries/packages) to offer further performance. A few of these gems solely work with particular variations of Ruby. The next two approaches remedy this problem.

Set up Ruby with Ruby Model Supervisor (RVM)

Ruby Model Supervisor, or rvm, is a command-line device that permits builders to put in, handle, and work with a number of Ruby environments. rvm has a number of options for builders in several phases of improvement, similar to manufacturing, improvement, testing, and Gem administration. Observe these steps to put in Ruby with rvm;

Step 1: Replace Ubuntu packages

Put together your system for set up utilizing this command;

sudo apt replace

Step 2: Add Ubuntu Dependencies

Ruby wants a number of dependencies to run correctly on Ubuntu. Run this command to put in all dependencies;

sudo apt set up curl g++ gcc autoconf automake bison libc6-dev libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev libreadline-dev libssl-dev

Step 3: Get the rvm set up script

Run this command;

curl -sSL https://get.rvm.io | bash -s secure

Step 4: Load the rvm script atmosphere

Run this command;

supply ~/.rvm/scripts/rvm

Step 5: Test the rvm checklist

Run this command;

rvm checklist recognized
image-100

Step 6: Set up Ruby

You’ll be able to set up a selected Ruby model or let rvm select the most recent model from the checklist. The checklist of obtainable Ruby variations is displayed whenever you run the command in step 5.

Use this command to put in a selected model, similar to ruby ​​3.0.0;

rvm set up ruby 3.0.0

Use this command to put in the most recent model on rvm;

rvm set up ruby

Step 6: Test the Ruby model

Run this command;

ruby -v

If Ruby is put in you’re going to get an identical output

image-98

Troubleshoot your RVM set up

You might have missed a step in your RVM set up and configuration course of.

Run this command to be sure you configured your shell accurately;

curl -sSL https://get.rvm.io | bash -s secure

Should you get this output;

curl: (60) SSL certificates drawback: unable to get native issuer certificates

  Extra particulars right here: http://curl.haxx.se/docs/sslcerts.html

Then which means you haven’t carried out the configuration correctly and that that you must set up CA certificates. Run this command to repair the issue;

 apt-get set up ca-certificates

Run this command to confirm that the modifications have been utilized;

 kind rvm | head -1

Should you do not see rvm as a operate on the output, the configuration is flawed.

image-102

Tips on how to uninstall/take away Ruby utilizing RVM

You’ll be able to uninstall a specific Ruby model out of your PC. You can too put off RVM and use one other device. Observe these steps;

Step 1: Test the present Ruby model with this command

rvm checklist
image-97

Step 2: Take away the recognized Ruby model, in our case it’s ruby-3.0.0. Use this command;

rvm take away 3.0.0
image-96

Step 3: Test if the uninstall was profitable with this command;

ruby -v

Step 4: Take away RVM

Despite the fact that we uninstalled ruby, RVM continues to be on our pc. Use this command to delete;

rvm implode

The system will ask you if you wish to take away rvm; kind ‘sure’ and enter.

image-95

Step 5: Delete RVM folders

Use this command;

rm -rf ~/.rvm

Step 6: Edit .bashrc, .bash_profile, .profile, and .zshrc.

In our case we use bashrc. Run this command to open your code editor;

nano ~/.bashrc

Discover all information with RVM and delete them. Save the modifications and exit the editor.

Set up Ruby utilizing rbenv

rbenv is a model management device that builders can use to modify between completely different Ruby variations. This device is helpful for ensuring you are utilizing the proper Ruby model for any venture you construct.

Observe these steps to put in rbenv on Ubuntu 22.10;

Step 1: Replace your system

Use this command to arrange your system for updates;

sudo apt replace

Step 2: Set up dependencies

Ruby wants a number of dependencies to run in your native machine. Set up them with this command;

sudo apt set up git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev

Step 3: Get the set up script from GitHub

On this step, you’ll use curl to get the set up script from GitHub. You then pipe it into bash to run the installer. Use this command;

curl -fsSL https://github.com/rbenv/rbenv-installer/uncooked/HEAD/bin/rbenv-installer | bash

Step 4: Add rbnev to your path

This step modifications the ~/.bashrc file, which lets you use the rbnev command line. Use this command;

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

Step 5: Enable rbnev to load mechanically

echo 'eval "$(rbenv init -)"' >> ~/.bashrc

Step 6: Apply the modifications

supply ~/.bashrc

Step 7: Test if the set up is profitable

kind rbenv
image-94

Step 8: Set up the to construct plug in

Test all obtainable Ruby variations with this command;

rbenv set up -l

Step 9: Set up Ruby

For demonstration functions, we’ll set up Ruby-3.2.1. Use this command;

Rbnev set up 3.2.1

Step 10: Set the put in Ruby model as default

rbenv international 3.2.1

Tips on how to replace rbnev

We put in rbnev utilizing Git. Each time a brand new model is created, you possibly can set up it via these instructions;

cd ~/.rbenv

git pull

Tips on how to uninstall Ruby utilizing rbnev

As time passes, your machine might have extra Ruby variations than you want. You’ll be able to take away such ruby ​​variations with this command;

rbenv uninstall (ruby model)

For instance, if you wish to uninstall Ruby 3.2.1, the command is;

rbenv uninstall 3.2.1

Tips on how to take away rbnev

Step 1: Take away rbnev information bashing.

Use this command to open the code editor;

nano ~/.bashrc

Step 2: Discover and delete these information, save and exit

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Step 3: Take away rbnev and associated information

Use this command;

rm -rf `rbenv root`

Now you can log off for the modifications to take impact.

Create a easy program in Ruby

Since we now have Ruby put in on Ubuntu, we will create a good day world to show the way it works. All Ruby information should have a .rb extension. We will use the built-in code editor for demonstration functions;

Step 1: Make one good day.rb file with nano.

Use this command

nano good day.rb

Step 2: Add this textual content to your editor;

places "good day world"

Step 3: Save and exit the editor

Step 4: Run this command;

ruby good day.rb

The next ought to be output;

image-101

Regularly Requested Questions

Is Ubuntu 22.10 paid software program?

No. Ubuntu is open supply software program you could obtain at no cost. Ubuntu operates beneath the GNU GENERAL PUBLIC LICENSE.

What are the completely different approaches to putting in Ruby on Ubuntu 22.10?

There are three foremost approaches; the Ubuntu repository, rvm and rbnev. The final two choices are essentially the most advisable.

Which is healthier between rvm and rbnev when putting in Ruby on Ubuntu 22.10?

Each rvm and rbnev are designed to perform the identical aim: managing completely different variations of Ruby. The selection between the 2 can be a matter of choice and style.

Can you’ve got each rvm and rbnev in your PC?

Sure, however not advisable. The 2 instruments are prone to battle if not configured accurately. Utilizing each instruments in the identical Ruby utility just isn’t advisable as it might result in inconsistencies.

Conclusion

You now have the completely different approaches you should utilize to put in Ruby on Ubuntu 22.10. The primary choice is the simplest, however the largest disadvantage is you could handle a number of Ruby choices in your native pc.

Each rvm and rbnev are designed to attain the identical objectives. Select between rvm And rbnev is a matter of choice. You should utilize each to put in libraries and frameworks like Ruby on Rails and Sinatra, which come packaged like gems.

If you wish to escape the duty of putting in Ruby in your pc, try the most effective on-line Ruby compilers to strive at the moment.

Leave a Comment

porno izle altyazılı porno porno