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
To install, go to https://rubyinstaller.org/downloads/
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 2.6.X (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.
Associate .rb and .rbw files with Ruby installation. Thanks to this, Ruby files can be launched by double-clicking or by typing the name of the script on the command line.
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:
1
2
3
4
5
|
1 - MSYS2 base installation 2 - MSYS2 system update (optional) 3 - MSYS2 and MINGW development toolchain Which components shall be installed? If unsure press ENTER [1,2,3] |
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:
1
|
ridk install |
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:
1
|
gem --help |
You should see gem help.
To display all available gem commands, run:
1
|
gem help commands |
To install the package, run a command of the form:
1
|
gem install PROGRAM_NAME |
More examples of installing packages will follow.
To show help about the installation command:
1
|
gem help install |
For example, to install the ‘rake’ program from a local directory or a remote server:
1
|
gem install rake |
Installing the ‘rake’ package only from a remote server:
1
|
gem install rake --remote |
Installing ‘rake’, but only version 0.3.1, even if there are unsatisfied dependencies, do the installation in the user directory:
1
|
gem install rake --version 0.3.1 --force --user- install |
List gem (packages) whose name begins with ‘D’:
1
|
gem list D |
List local and remote gem whose name contains ‘log’:
1
|
gem search log --both |
The previous command is used to search for packages by name.
List only remote (non-local) gem whose name contains ‘log’:
1
|
gem search log --remote |
Delete ‘rake’:
1
|
gem uninstall rake |
View information about RubyGems:
1
|
gem environment |
Update all gem programs in the system:
1
|
gem update |
Update local version of RubyGems:
1
|
gem update --system |
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:
1
|
gem install bundler |
To upgrade bundle, run the command:
1
|
gem update bundle |
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:
1
|
bundle install |
This command will install all the dependencies listed in the Gemfile.
ทิ้งคำตอบไว้
คุณต้องเข้าสู่ระบบ เพื่อจะพิมพ์ความเห็น