Ruby emulator and tips how to use
Ruby emulator and tips how to use
Ethical hacking and penetration testing
InfoSec, IT, Kali Linux, BlackArch
How to install and use Ruby on Windows
Why install Ruby
Ruby is a scripting language, that is, pre-compilation is not required to run programs. In this sense, Ruby is an analogue of PHP, Python, PERL and others.
Ruby is a fairly popular language and many interesting programs are written on it; in scope of InfoSec, the well-known WPScan, WhatWeb, Wayback Machine Downloader and others can be cited as examples.
By installing Ruby on Windows, you can run programs written in this language, as well as learn this programming language and write your own scripts.
By the way, Ruby, like PHP, Python and PERL, can be a web server module, and scripts written in this language can be used as backend of a website or service.
How to install Ruby on Windows
There you will see many installer options that differ not only in versions, but also in the composition of the downloaded files. Executable files are self-contained installers for Windows that include the Ruby language, runtime, important documentation, and more. If you do not know which version to install in order to get started with Ruby, the Ruby+Devkit * (x64) is recommended. It provides the largest number of compatible gem (Ruby packages) and installs MSYS2-Devkit along with Ruby, so gem with C-extensions can be compiled immediately after installation.
Run the downloaded file. In this window we can select the settings:
The installation folder can be left unchanged.
Add Ruby executables to your PATH – means adding a directory with Ruby executables to the system variable. This is recommended to do for in future to avoid specifying the full path to the script interpreter each time the Ruby script is run.
Use UTF-8 as default external encoding.
I selected all three checkmarks and entered C:\Ruby26 as the installation folder:
As you can see on the next page, the Ruby package itself takes up a bit of space, but the MSYS2 development toolkit offered for installation takes up a lot of space. I highly recommend installing MSYS2 because, in addition to the ability to compile packages for Ruby mentioned above, MSYS2 provides a console environment with Linux features (something like Cygwin does, but with additional features).
Leave a checkmark on the last window to configure the MSYS2 developer tools and click Finish.
Further we are offered:
Just press ENTER to complete all three actions:
Everything is completed, to exit, press ENTER:
By the way, if you carefully watched what was happening on the screen, you might notice pacman. There really is a pacman package manager in this console environment. We will return to other functions of MSYS2 a bit later.
How to update Ruby on Windows
To upgrade to the latest patch (that is, the minor version, for example from 2.5.1 to 2.5.4), it is enough to launch a new version of the installer. Installed gem (packages from the Ruby repository) are not overwritten and will work with the new version without reinstalling. To upgrade the installation, just use RubyInstaller without Devkit. You can update Devkit separately by running the following command at the Windows command prompt:
When a new major version is released, it cannot be updated by installing it in the same directory as the previous one. For example, if the previous version of the installation is RubyInstaller-2.5.x, and the new version is RubyInstaller-2.6.x, then you need to install it either in a new directory or delete the old version and install a new one instead, since gem (programs) with C extensions are not compatible between ruby-2.5 and 2.6.
How to install and use gem on Windows
RubyGems is a package manager for Ruby. Using it, you can install various programs and their dependencies, installation can be done both from the source code on the local system, and from remote application sources.
The Ruby installation shown above also installs gem:
You should see gem help.
To display all available gem commands, run:
To install the package, run a command of the form:
More examples of installing packages will follow.
To show help about the installation command:
For example, to install the ‘rake’ program from a local directory or a remote server:
Installing the ‘rake’ package only from a remote server:
Installing ‘rake’, but only version 0.3.1, even if there are unsatisfied dependencies, do the installation in the user directory:
List gem (packages) whose name begins with ‘D’:
List local and remote gem whose name contains ‘log’:
The previous command is used to search for packages by name.
List only remote (non-local) gem whose name contains ‘log’:
View information about RubyGems:
Update all gem programs in the system:
Update local version of RubyGems:
How to install bundler
bundler is a Ruby dependency manager. This manager is useful when installing other programs written in Ruby.
To install bundler on Windows, run:
To upgrade bundle, run the command:
If you install the program from the source code and there is a Gemfile file, then go to the folder with this program and run the command in it:
This command will install all the dependencies listed in the Gemfile.
To see where gem packages are installed using bundle, use the command:
How to install the Ruby program on Windows. How to run a Ruby program on Windows
The following are a few examples of installing and using Ruby programs on Windows.
Recovering sites from the Internet Archive in Windows
Let’s start with the Wayback Machine Downloader program, which completely restores sites from the web archive.
To install Wayback Machine Downloader, just do:
To check the operability of the program, run site restoration from the Internet Archive:
The program successfully completed the work:
How to Install WhatWeb on Windows
WhatWeb identifies websites. The purpose of this program is to answer the question “What is this website?”. WhatWeb recognizes web technologies, including a content management system (CMS), blogging platforms, statistics/analytics packages, JavaScript libraries, a web server and embedded devices. WhatWeb has over 1700 plugins, each of which is for recognizing one or the other. WhatWeb also identifies version numbers, email addresses, account IDs, web platform modules, SQL errors and more.
Let’s start by searching WhatWeb in the Ruby package repository:
Only simple_whatweb found (0.4.1).
Even if it’s WhatWeb, the version is very old. Therefore, on Windows, install WhatWeb from the source code.
Unzip this folder. Open a command prompt and navigate to this folder:
Run the command:
The following command will show the help for the program:
Run the site check:
How to install WPScan on Windows
To install and run WPScan on Windows is tricky a bit, so the tutorial was divided in separate article “How to Install and Run WPScan on Windows”.
What is MSYS2. How to use MSYS2
We have already installed MSYS2 in order to gain access to compilation tools, thanks to which we can install any Ruby package. In fact, MSYS2 is based on Cygwin and contains a large number of Linux utilities.
MSYS2 provides a shell for bash, Autotools, make, gcc, pacman, sh, and many other packages. Of particular note is the pacman package manager.
To activate the MSYS2 working environment, open a command prompt or powershell console and run there:
As a result, many Linux utilities will immediately become available for work, as well as the Pacman package manager, with which you can install new packages or update existing ones. When installing packages, Pacman monitors the dependencies and installs them.
To update all packages:
To search for a package:
To list all available packages:
How to configure Ruby as an Apache module on Windows
Ruby scripts can be run in an Apache environment similar to running PHP scripts. To do this, you need to make a little configuration.
I installed the web server according to this tutorial, if you installed according to another manual, then edit the paths to fit your environment.
Open the httpd.conf file for editing, I have it located on the path C:\Server\bin\Apache24\conf\httpd.conf.
Find the line there
and add ExecCGI to it. You should get the following line (ATTENTION: you may have different the set of options):
Interactive CLI (Command Line Interface) applications with Ruby Gems.
Am I the only one who didn’t like using the CLI just because of how dull and boring it seemed compared to the powers of web apps?
If your answer is no, then keep on reading and gain the necessary knowledge to make your CLI interactive and colorful, but if your answer was yes I’d recommend you using the back link now.
Basic requirements to set up a gem.
Taking into consideration you already have all the requirements needed to run a ruby app installed on your computer/vm I ll explain the basic installation process so you can get the next gems up and running.
1. Installing the gem.
2. Requiring the gem.
If you are using a gem that you didn’t install through bundle ruby it will most likely ask you to require that gem inside the file you are trying to run before any other code.
3. Optional for some gems creating an instance of gem class.
Some gems like the TTY ones ask you that in order to start using the gem you should create in this case ‘prompt’ so you can begin using all the methods that that come with it.
Later you’ll see longer usage examples regarding this.
Gems I enjoy using and recommend for an interactive CLI app.
TTY-Prompt
This gem is my favorite and in my opinion the most useful out of the gems in this article. Some useful features are:
As mentioned above, you can add different menu and input options for the user to interact with and at the same time you will be able to save the users input to your app and use the data accordingly.
For you to be able to use this gem you’ll first need to install the gem and create the instance of the gem class. In this case it would be something like:
Now all thats left is checking the documentation and using the method that you feel meets your needs best, I strongly recommend reading the documentation carefully because this gem can do so many things that you as a developer will consider amazingly important for your app and to provide a better UX.
In the above example you can see 3 different choices where each of them has a name to display e.g. ‘Scorpion’ with its value of ‘1’, ‘Jax’ with a value of a string and ‘Kano’ is disabled which makes him impossible to select. What I liked the most about all this is the fact that you can even pass methods as values, so when you chose an option with a method as its value the method will run accordingly, making your app super interactive and saving you the trouble of writing multiple conditional statements based on the users input.
Look at the gif above for a fast example of how to use a method as a value.
HackWare.ru
Этичный хакинг и тестирование на проникновение, информационная безопасность
Как установить и использовать Ruby в Windows
Для чего устанавливать Ruby
Ruby — это скриптовый язык, то есть для запуска программ не требуется предварительная компиляция. В этом смысле Ruby является аналогом PHP, Python, PERL и других.
Ruby достаточно популярный язык и на нём написано много интересных программ; если говорить применительно к InfoSec, то в качестве примеров можно привести знаменитые WPScan, WhatWeb, Wayback Machine Downloader и другие.
Установив Ruby на Windows вы сможете запускать программы, написанные на этом языке, а также изучать это язык программирования и писать свои собственные скрипты.
Кстати, Ruby, наравне как и PHP, Python и PERL, может быть модулем веб-сервера и скрипты, написанные на этом языке, можно использовать в качестве программной основы веб-сайта или сервиса.
Как установить Ruby на Windows
Там вы увидите много вариантов установщика, которые различаются не только версиями, но и составом скаченных файлов. Исполнимые файлы являются самодостаточными установщиками для Windows, которые включают язык Ruby, окружение выполнения, важную документацию и прочее. Если вы не знаете, какую версию установить, чтобы начать знакомство с Ruby, то рекомендуется установщик Ruby+Devkit * (x64). Он предоставляет самое большое число совместимых gem (пакеты Ruby) и устанавливает MSYS2-Devkit вместе с Ruby, благодаря чему gem с C-расширениями могут быть скомпилированы сразу после завершения установки.
Запустите скаченный файл. В этом окне мы можем выбрать настройки:
Папку установки можно оставить без изменения.
Add Ruby executables to your PATH – означает добавить каталог с исполнимыми файлами Ruby в системную переменную. Это рекомендуется сделать, чтобы не указывать при каждом запуске скрипта Ruby полный путь до интерпретатора скриптов.
Use UTF-8 as default external encoding – означает использовать кодировку UTF-8 в качестве внешней кодировки по умолчанию.
Я выбрал все три галочки и в качестве папку установки ввёл C:\Ruby26:
Как видно на следующей странице, сам пакет Ruby занимает немного места, но много места занимается предлагаемая к установке набор инструментов разработчика MSYS2. Я настоятельно рекомендую установить MSYS2, поскольку кроме упомянутой выше возможности компилировать пакеты для Ruby, MSYS2 обеспечивает консольное окружение с функциями Linux (примерно как это делает Cygwin, но с дополнительными возможностями).
Оставьте галочку на последнем окне для настройки инструментов разработчика MSYS2 и нажмите Finish.
Далее нам предлагается:
Просто нажимаем ENTER для выполнения всех трёх действий:
Всё завершено, для выхода нажмите ENTER:
Кстати, если вы внимательно смотрели за происходящем на экране, то могли заметить pacman. В этом консольном окружении действительно есть менеджер пакетов pacman. К другим функциями MSYS2 вернёмся чуть позже.
Подробнее о Pacman смотрите в статьях:
Как обновить Ruby на Windows
Для обновления до последнего патча (то есть минорной версии, к примеру с 2.5.1 до 2.5.4), достаточно запустить новую версию установщика. Установленные gem (пакеты из репозитория Ruby), не перезаписываются и будут работать с новой версией без переустановки. Для обновления установки достаточно использовать RubyInstaller без Devkit. Обновить Devkit можно отдельно запустив в командной строке Windows следующую команду:
При выходе новой мажорной версии её нельзя обновить установкой в ту же директорию, что и предыдущая. К примеру, если предыдущая версия установки RubyInstaller-2.5.x, а новая версия RubyInstaller-2.6.x, то её нужно установить либо в новую директорию, либо удалить старую версию и вместо неё установить новую, поскольку gem (программы) с C расширениями не совместимы между ruby-2.5 и 2.6.
Как установить и использовать gem в Windows
RubyGems — это менеджер пакетов для Ruby. С помощью него можно установить различные программы и их зависимости, установку можно делать как из исходного кода на локальной системе, так и с удалённых источников приложений.
Показанная выше установка Ruby также устанавливает и gem, чтобы в этом убедиться выполните команду:
Вы должны увидеть справку по использованию gem.
Чтобы вывести все доступные команды gem, выполните:
Чтобы установить пакет запустите команду вида:
Больше примеров по установке пакетов будет далее.
Чтобы показать справку о команде установки:
К примеру, для установки программы ‘rake’ из локальной директории или удалённого сервера:
Установка пакета ‘rake’ только с удалённого сервера:
Установка ‘rake’, но только версии 0.3.1, даже если имеются неудовлетворённые зависимости, установку сделать в пользовательскую директорию:
Вывести список gem (пакетов), чьё имя начинается на ‘D’:
Вывести список локальный и удалённых gem, чьё имя содержит ‘log’:
Предыдущая команда используется для поиска пакетов по имени.
Вывести список только удалённых (не локальных) gem, чьё имя содержит ‘log’:
Просмотреть информацию о RubyGems:
Обновить все программы gem в системе:
Обновить локальную версию RubyGems:
Как установить bundler
bundler — это менеджер зависимостей Ruby. Данный менеджер пригодится при установке других программ, написанных на Ruby.
Для установки bundler в Windows выполните:
Для обновления bundle выполните команду:
Если вы устанавливаете программу из исходного кода и там присутствует файл Gemfile, то перейдите в папку с этой программой и выполните в ней команду:
Эта команда установит все перечисленные в файле Gemfile зависимости.
Чтобы увидеть, где установленные с помощью bundle пакеты gem, используйте команду:
Как установить программу Ruby в Windows. Как запустить программу Ruby в Windows
Далее рассмотрим несколько примеров установки и использования программ на Ruby в Windows.
Восстановление сайтов из Интернет Архива в Windows
Начнём с программы Wayback Machine Downloader, которая полностью восстанавливает сайты из веб архива.
Для установки Wayback Machine Downloader достаточно выполнить:
Запустим для проверки работоспособности программы восстановление сайта из Архива Интернета:
Программа успешно завершила работу:
Как установить WhatWeb в Windows
WhatWeb идентифицирует веб-сайты. Цель этой программы ответить на вопрос «Чем является этот веб-сайт?». WhatWeb распознает веб-технологии, в том числе систему управления контентом (CMS), платформы для ведения блогов, пакеты статистики/аналитики, библиоотеки JavaScript, веб-сервера и встроенные устройства. WhatWeb имеет более 1700 плагинов, каждый из которых для распознавания чего-то одного. WhatWeb также идентифицирует номера версий, email адреса, ID аккаунтов, модули веб-платформ, SQL ошибки и прочее.
Начнём с поиска WhatWeb в репозитории пакетов Ruby:
Найдено только simple_whatweb (0.4.1).
Даже если это WhatWeb, то версия очень старая. Поэтому на Windows установим WhatWeb из исходного кода.
Распакуйте эту папку. Откройте командную строку и перейдите в эту папку:
Следующая команда покажет справку по программе:
Запустим проверку сайтов:
Установка WPScan в Windows
Что такое MSYS2. Как пользоваться MSYS2
Мы установили уже MSYS2 для того, чтобы получить доступ к инструментам компиляции, благодаря которым мы сможем установить любой пакет Ruby. На самом деле MSYS2 основывается на Cygwin и содержит большое количество утилит Linux.
MSYS2 предоставляет оболочку bash, Autotools, make, gcc, pacman, sh и многие другие пакеты. Особенно следует отметить менеджер пакетов pacman.
Для активации рабочего окружения MSYS2 откройте командную строку или консоль powershell и выполните там:
В результате сразу станут доступны для работы многие утилиты Linux, а также менеджер пакетов Pacman, с помощью которого можно установить новые пакеты или обновить имеющиеся. При установке пакетов Pacman следит за зависимостями и устанавливает их.
Ruby Programming/Installing Ruby
The first step to get started in Ruby development is setting up your local environment. Due to differences between various operating systems we will cover multiple of them. If you are already able to use a terminal emulator and know how to install Ruby yourself, you can skip this chapter (after you installed Ruby). Otherwise we will guide you through the process of installing Ruby on your computer.
Contents
Terminal emulators [ edit | edit source ]
Knowing how to use a terminal emulator is very useful if you are programming. Usually it will provide the most straightforward access to commands and applications instead of hiding it behind graphical interfaces. On the other hand they are often daunting to beginners since they are often perceived to require a deep understanding of a computer when in fact often only knowing the very basics is already enough to get started.
Unix-like operating systems [ edit | edit source ]
One of the most commonly used shells in the Unix-like operating systems (i.e. macOS, GNU/Linux, BSD) is the Bash shell, in fact it is very often the default shell. To start a session you will often use a terminal emulator, which allow you to use a terminal session at the same time as other graphical applications. It doesn’t really matter, which terminal emulator you use, generally you want one that has color and Unicode support. In macOS you can use Terminal.app which you can find under Applications > Utilities. A popular alternative is iTerm. On most Linux distributions you will usually be provided with at least one terminal emulator by default, otherwise you might want to try Terminator, Konsole, rxvt-unicode or something different.
When you open a new window or tab in your terminal emulator of choice you will be shown your prompt. What it looks like exactly depends a lot on configuration, which can vary greatly from OS to OS (you can configure everything to your likings, however this exceeds the scope of this short introduction). Generally it will indicate your current working directory, username and hostname. When working in the shell your session always has current working directory. Commands that accept relative filenames will use that directory as the base directory to look for files. By default you are in your user’s home folder, which is often abbreviated with a tilde (
To execute a command you just type it into the shell and press enter.
A very brief summary of other useful commands:
cat FILE : display the contents of a file.
mkdir DIR : create a directory.
Windows [ edit | edit source ]
Windows doesn’t use the Bash shell and in the past it was hard to get Bash to work on Windows. Users of Windows 10 Anniversary Update build 14393 or later however now have the ability to install a Ubuntu subsystem which will essentially provide them with a working Bash shell and access to many commands found in the Ubuntu Linux distribution. Users wishing to use Bash on Windows 10 are advised to follow the official installation instructions from Microsoft. After the installation you can basically follow the instructions for Ubuntu/Debian.
If you don’t want to do that you have two options:
System-wide installation [ edit | edit source ]
A common and easy way to install Ruby is to perform a system-wide installation. Depending on the operating system installation procedures will be different (if required at all).
macOS [ edit | edit source ]
If you want to install a more recent version of Ruby, you can:
Linux [ edit | edit source ]
Where this is not the case, or you want to update the installed version, you should use your distribution’s package manager. Here we will provide information for some popular Linux distributions here, however it is recommended to users of all distributions to familiarize themselves with their distribution’s package manager, since this will allow for the most efficient software management. Whether this is a command-line or graphical application depends on the offerings of the distribution and personal preference of the user.
Debian / Ubuntu [ edit | edit source ]
The package manager Synaptic provides graphical package management. It is installed by default under Ubuntu and has to be installed manually on Debian (by running sudo apt-get install synaptic from the command line).
Instead of using Synaptic you can also use apt directly from the command-line (you can find further information in the Debian Wiki’s article on Package Management). Execute sudo apt-get install ruby from the command line to install Ruby.
Fedora [ edit | edit source ]
Arch Linux [ edit | edit source ]
Mandriva Linux [ edit | edit source ]
On Mandriva Linux, install Ruby using the command-line tool urpmi.
PCLinuxOS [ edit | edit source ]
On PCLinuxOS, install Ruby using either the graphical tool Synaptic or the command-line tool apt.
Red Hat Linux [ edit | edit source ]
On Red Hat Linux, install Ruby using the command-line tool RPM.
Windows [ edit | edit source ]
Ruby does not come preinstalled with any version of Microsoft Windows. However, there are several ways to install Ruby on Windows.
Windows is slow [ edit | edit source ]
Currently Ruby on windows is a bit slow. Ruby isn’t optimized for windows, because most core developers use Linux. Though 1.9.2 passes almost all core tests on windows.
Most of today’s slowdown is because when ruby does a
it searches over its entire load path, looking for a file named xxx, or named xxx.rb, or xxx.so or what not. In windows, doing file stat’s like that are expensive, so requires take a longer time in windows than linux. 1.9 further complicates the slowdown problem by introducing gem_prelude, which avoids loading full rubygems (a nice speedup actually), but makes the load path larger, so doing require’s on windows now takes forever. To avoid this in 1.9.2, you can do a
which reverts to typical load behavior.
If you want to speed it up (including rails) you can use
Which have some work arounds to make loading faster by caching file locations.
Also the «rubyinstaller» (mingw) builds are faster than the old «one click» installers If yours comes from rubyinstaller.org, chances are you are good there.
NB that Jruby tends to run faster but start slower, on windows, than its MRI cousins. Rubinius is currently not yet windows compatible.
Building from Source [ edit | edit source ]
If your distro doesn’t come with a ruby package or you want to build a specific version of ruby from scratch, please install it by following the directions here. Download from here.
Compile options [ edit | edit source ]
Building with debug symbols [ edit | edit source ]
If you want to install it with debug symbols built in (and are using gcc—so either Linux, cygwin, or mingw).
Optimizations [ edit | edit source ]
To set the GC to not run as frequently (which tends to provide a faster experience for larger programs, like rdoc and rails), precede your build with
though you might be able to alternately put those in as opt or debug flags, as well.
Testing Installation [ edit | edit source ]
The installation can be tested easily by executing:
This should produce an output similar to:
If this shows up, then you have successfully installed Ruby. However if you get an error similar to:
then you did not successfully install Ruby.
Installing Ruby
Ruby Course
Introduction
Before we start learning, we’ll need to install Ruby first. This section is where you could potentially encounter a lot of errors.
Before continuing, let’s review a few best practices to keep in mind:
Now, let’s get started!
Step 1: Install Updates, Packages and Libraries
Before we can install Ruby, we need to install some base packages.
Step 1.1: Open the Terminal
We’ll use the terminal to install all of the programs.
If you’re using Ubuntu or Xubuntu, simply press Ctrl + Alt + T to open the terminal. (This may work in other Linux distributions; you’ll have to try!)
Step 1.2: Update Linux
The rest of the installation will take place inside the terminal window.
Step 1.3: Install Packages and Libraries
Next, you need to install some required packages that do not come preinstalled. Be sure to copy and paste this command.
Step 2: Install Ruby
Step 2.1: Install rbenv
First, you need to clone the rbenv repository.
Next, we’ll add some commands to allow rbenv to work properly. We can use the Linux echo command to make it easy.
Note: Run these commands one by one in sequence. They will not provide any output if done properly. Again, be sure to copy and paste these commands.
After running the final exit command, you will need to close out of all open terminals and open a new terminal (see Step 1.1 above).
Next, you need to install ruby-build to help compile the Ruby binaries. Run these commands in the terminal to create a directory for the ruby-build plugin and then download it to the proper directory.
from your terminal to verify that rbenv has been installed correctly. You should get an output with a version number similar to this:
If you do not get a version number at all (anything not starting with rbenv 1. ), please ask for help in the Odin Project Chat Room.
Step 2.2: Install Ruby
Inside the terminal, run this command:
You may get this error message:
If so, we run the suggested command:
Once Ruby is installed, you need to tell rbenv which version to use by default. Inside the terminal, type:
The above command should return something similar to this:
where x represents the version available at the time you installed Ruby.
Well done! Pat yourself on the back! The hard part is done, and it’s time to move on to the next lesson!
Step 1: Install Packages and Libraries
Before we can install Ruby, we need to install some base packages. We will use the terminal to install all of the programs.
Step 1.1: Open the Terminal
In your Applications folder, find “Utilities” and double click “Terminal”. Alternatively, using Spotlight ( CMD + Space ) or Launchpad, type “Terminal”.
The rest of the instructions are done inside this terminal window.
Step 1.2: Install Xcode
First, you need to install Xcode, which is a program provided by Apple for programming. Xcode will install many programs that are needed for Ruby and Git and should take 10-15 minutes to install.
Step 1.3: Install Homebrew
The next program you need to install is Homebrew, which makes it easy to install other programs you’ll need. From inside the terminal, type the following:
Congratulations! You’ve installed the prerequisites!
Step 2: Install Heroku
Heroku is a place to host your Rails applications.
Step 2.1: Install Heroku
Next, install Heroku:
This command will install the command line interface for Heroku, a free website that can host your Ruby on Rails applications. You’ll learn more about this later.
Step 3: Install Ruby
Step 3.1: Install ruby-build
First, let’s install ruby-build :
ruby-build will make it possible to install our Ruby version of choice.
Step 3.2: Install rbenv
Then, run this command:
You should see one of two messages after the command has run.
You’ll do as it suggests by running either of the following commands in the terminal.
If the previous message stated you should append to your bash_profile then run:
Otherwise if it mentioned zshrc then run:
You’ll notice nothing happened in the terminal. That’s okay and is typical response for many terminal commands. At this point, take note of the page and step number you are on, close everything, do a full reboot and log back into your profile. After logging back in, re-open the terminal (see Step 1.1).
Step 3.3: Install Ruby
We can now (finally) install Ruby! Our curriculum currently uses version 3.1.2, which will allow you to complete this path’s materials and content without error. We upgrade the material to accommodate newer versions as necessary. Without further ado, let’s get going!
First, let’s upgrade ruby-build :
Now we’re ready to install our desired version of Ruby:
Once Ruby is installed, you need to tell rbenv which version to use by default. Inside the terminal, type:
If you don’t see the output above, log off and log back on, then try again.
Well done! Pat yourself on the back! The hard part is done, and it’s time to move on to the next lesson!
Extras
If you are using Visual Studio Code as your IDE, you can install the “Ruby” extension which will provide you with semantic highlighting and formatting support. This is optional, but it is a quick install; go to the “Extensions” tab in VSC (Ctrl+Shift+X), search “Ruby”, and click install on the first one. Congratulations, the extension is now installed (you can also uninstall the extension from here).
If you are using a different IDE, a quick Google search such as “Ruby programming extensions for (your IDE here)” should provide you with the resources to get started. Free support extensions can help make your programming go more smoothly, and there are tons of extensions for all languages (not just Ruby).