go to  ForumEasy.com   
JavaPro  
 
 
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » Java Deploying » How to Install Ruby on Ubuntu 16.04 LTS
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: How to Install Ruby on Ubuntu 16.04 LTS
Linux
member
offline   
 
posts: 120
joined: 01/24/2011
from: San Jose, CA
  posted on: 09/06/2017 01:09:26 AM    Edit  |   Quote  |   Report 
How to Install Ruby on Ubuntu 16.04 LTS
Ruby is a dynamic programming language you can use to write anything from simple scripts to games and web applications. It was first released in Japan in 1993, but gained popularity in 2005 as a language for server-side web development. Ruby is designed to be easy to use and fun for beginners, but powerful enough to create complex systems. It's a great choice for beginners and experienced developers alike.

While there are many ways to install Ruby on Ubuntu, the easiest method is to use RVM, the Ruby Version Manager. It downloads the latest version of Ruby and installs all of the prerequisite libraries.

 Profile | Reply Points Earned: 0
Linux
member
offline   
 
posts: 120
joined: 01/24/2011
from: San Jose, CA
  posted on: 09/06/2017 01:19:22 AM    Edit  |   Quote  |   Report 
Step 1 -- Install RVM, the Ruby Version Manager
Firstly request the public key to verify the legitimacy of the RVM release we will be downloading, which is signed with the matching private key. To do this run this command.

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3


Then the script to get RVM
curl -sSL https://get.rvm.io | bash -s stable

Downloading https://github.com/rvm/rvm/archive/1.29.2.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.2/1.29.2.tar.gz.asc
gpg: Signature made Thu 22 Jun 2017 09:18:38 AM PDT using RSA key ID BF04FF17
gpg: Good signature from "Michal Papis (RVM signing) <mpapis@gmail.com>" [unknown]
gpg:                 aka "Michal Papis <michal.papis@toptal.com>" [unknown]
gpg:                 aka "[jpeg image of size 5015]" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 409B 6B17 96C2 7546 2A17  0311 3804 BB82 D39D C0E3
     Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36  166B E206 C29F BF04 FF17
GPG verified '/home/administrator/.rvm/archives/rvm-1.29.2.tgz'

Installing RVM to /home/administrator/.rvm/
    Adding rvm PATH line to /home/administrator/.profile /home/administrator/.mkshrc
/home/administrator/.bashrc /home/administrator/.zshrc.
    Adding rvm loading line to /home/administrator/.profile /home/administrator/.bash_profile
/home/administrator/.zlogin.
Installation of RVM in /home/administrator/.rvm/ is almost complete:

  * To start using RVM you need to run `source /home/administrator/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

# administrator,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.

In case of problems: https://rvm.io/help and https://twitter.com/rvm_io


Finally set the source to use RVM
source ~/.rvm/scripts/rvm

 Profile | Reply Points Earned: 0
Linux
member
offline   
 
posts: 120
joined: 01/24/2011
from: San Jose, CA
  posted on: 09/06/2017 01:28:03 AM    Edit  |   Quote  |   Report 
Step 2 -- Install Ruby via RVM
Now you can use the rvm command to install the latest version of Ruby:

rvm install ruby --default

Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/16.04/x86_64/ruby-2.4.0.tar.bz2
Checking requirements for ubuntu.
Installing requirements for ubuntu.
Updating system.....
Installing required packages: gawk, libyaml-dev, sqlite3, autoconf, libgdbm-dev, libncurses5-dev,
automake, libtool, bison, libffi-dev, libreadline6-dev.......-
Requirements installation successful.
ruby-2.4.0 - #configure
ruby-2.4.0 - #download
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16.4M  100 16.4M    0     0  3801k      0  0:00:04  0:00:04 --:--:-- 3802k
ruby-2.4.0 - #validate archive
ruby-2.4.0 - #extract
ruby-2.4.0 - #validate binary
ruby-2.4.0 - #setup
ruby-2.4.0 - #gemset created /home/administrator/.rvm/gems/ruby-2.4.0@global
ruby-2.4.0 - #importing gemset /home/administrator/.rvm/gemsets/global.gems.....
ruby-2.4.0 - #generating global wrappers........
ruby-2.4.0 - #gemset created /home/administrator/.rvm/gems/ruby-2.4.0
ruby-2.4.0 - #importing gemsetfile /home/administrator/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.4.0 - #generating default wrappers........


This process will download and install Ruby and its components, and make this version of Ruby the default version your system will use. This will avoid conflicts if you have a version of Ruby already installed.


You can check the version:
ruby -v

ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]


 Profile | Reply Points Earned: 0
Linux
member
offline   
 
posts: 120
joined: 01/24/2011
from: San Jose, CA
  posted on: 09/06/2017 01:43:37 AM    Edit  |   Quote  |   Report 
Step 3 -- Run a simple ruby program
Hello, World:
nano hello.rb


Inside file type:
puts "Hello, Wolrd"

Press Ctrl-X and then Y to save the file

Now you can run it:
ruby hello.rb


Output:
Hello, World!



Now make it more interactive:
puts "Hello, Wolrd"
puts ""

puts "Please enter your name."
name = gets.chop
puts "Hi, #{name}! I'm Ruby!"


Now you run it again:
ruby hello.rb


Output:
Hello, World!

Please enter your name.
Sam
Hi, Sam! I'm Ruby!

 Profile | Reply Points Earned: 0

 
Powered by ForumEasy © 2003-2005, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.