23
loading...
This website collects cookies to deliver better user experience
Windows
To install ruby on a Windows machine it's actually pretty easy thanks to RubyInstaller. I won't go over how to install ruby using RubyInstaller cause it's really easy, just follow the steps of the installer and you will be good to go.
Gnu/Linux
Installing ruby on a Gnu/Linux machine is a bit harder depending on how much comfortable you are with the terminal of course. As far as I know there is not a one click installer for ruby as RubyInstaller for Windows. On Gnu/Linux you generally have two options:
Package Manager
Using the package manager of your distribution is generally not advised cause most of the time it doesn't have an up to date version of ruby. So I would avoid using this option even though it's easier.
Using a Version Manager
This option is generally preferred cause not only you can install the latest version of ruby but you can also manage multiple versions of ruby in your system. There are a lot of options and I will highlight the most used ones. We can use rvm (ruby version manager), rbenv with ruby-build and finally ruby-install with chruby.
rvm --version
rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
rvm install 3.0.2
rvm use 3.0.2
ruby --version
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
cd 100_days_of_ruby/
mkdir Day_1 && cd Day_1/ && touch hello.rb
puts "Hello, World!"
ruby hello.rb
puts
, which prints a string of characters and also goes to the next line. We provided a string of characters by typing Hello, World! inside of " "
. Finally to run the program we typed ruby hello.rb
. Basically when we want to run a ruby program we just type ruby
and the path to our .rb
file.