Skip to main content

Ruby Programming Tutorial - Lesson 01 - Installation of Ruby Environment - bearshares.com

logo1.jpg
Hey Friends,
This is the first part of ruby programming Lessons. In this part, we are going to learn,
setting up the Ruby environment for development.
I suggest doing it on linux operating system .. Ubuntu 16.04 is suggested ..
If you are on windows, there is an easier method of installing ruby, that is via
rubyinstaller.
You can find it here :)
https://rubyinstaller.org/downloads/
otherwise if you are on linux operating system, follow this guide, I am sure we are going to have so much fun.

Let us Begin :)

Execute this command in your terminal. we are installing ruby via rbenv .. so first lets get it
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
ruby1.JPG
After cloning rbenv execute these two commands.
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
ruby2.JPG
Next step is sourcing rbenv,
that you can do by typing following command
source ~/.bashrc
after sourcing it, you can check to see if rbenv is installed properly, by doing so.
type rbenv
your output should be similar to as shown below.
ruby3.JPG
Following command will allow us to use "rbenv install" command,
which comes in handy, when installing different versions of ruby programming language.
Sometimes, if we wish to clone a github project and it is build with different version of language.
rbenv install command helps us switching between different versions of ruby programming language,
You will see that it requires only one command to install a different version of ruby. :)
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

Following command allows us to see, what versions of ruby programming language are available.
we can choose any version from the list, and install it easily :)
rbenv install -l

next step is to install the version of ruby programming you want ..
in our case we will install
ruby 2.5.0 which is latest stable.
rbenv install 2.5.0

and if you installed many versions of ruby , you set to choose a default version for your ruby programs
by typing and executing this command.
rbenv global 2.5.0
final step is to verify if everything is installed correctly , we can check that by executing this command,
ruby -v
which returns us the version of ruby which we just installed :)


If you have done everything correctly .. you must be proud of yourself :) because you just installed ruby development environment ... We can now do all the magic we want to do..

Originally posted via my blog on bearshares.com
https://bearshares.com/programming/@ruby/ruby-programming-tutorial-lesson-01-installation-of-ruby-environment

Comments

Popular posts from this blog

Ruby Programming Tutorial - Lesson 02 - Constant values and Data types - bearshares.com

If you followed my previous lecture, you should be ready to write some ruby programs now :) Before we start .. Download and install your favorite text editor software. in my Case i am using Visual studio code. print "Hello World" Lets write our first ruby program now, creating a new file, and saving it with .rb extension will create a ruby program for us. its time to execute the code, to see if it works we can execute a ruby program doing this. ruby variable.rb Constants Now lets talk about constant values. every number like, 1, 2, 3, 1.34, 1.09, 0.0000034, or -1.98 is a constant value. it is called constant because it never changes.. like 2 is a constant value which always remains to be 2 :) Similarly each alphabet characters are also constant values like "a", "b" , "c" these are all constant values.. lets type some constant values. and see what we get when we execute our program Variables Variables are value holders