- Installing Ruby
- Choose Your Installation Method
- Package Management Systems
- apt (Debian or Ubuntu)
- yum (CentOS, Fedora, or RHEL)
- snap (Ubuntu or other Linux distributions)
- portage (Gentoo)
- pacman (Arch Linux)
- Homebrew (macOS)
- FreeBSD
- OpenBSD
- Ruby on OpenIndiana
- Other Distributions
- Installers
- ruby-build
- ruby-install
- RubyInstaller
- Ruby Stack
- Managers
- asdf-vm
- chruby
- rbenv
- RVM (“Ruby Version Manager”)
- Building from Source
- 💊 How To Install #RubyonRails 💊 on Windows 7/8/10 → Complete Tutorial 2019 (May 2020)
- Step-By-Step Tutorial on How To Install Ruby, Rails, RubyGems, Git, RMagick, MYSQL2 & SQLite3 on Windows…
- Overview
- 💾 Download RubyInstaller (IMPORTANT)
- 1️⃣ Identify Windows Architecture
- Установка Ruby On Rails на Windows Server
- Что это такое?
- Загрузка и установка
- Настройка
- All guides / Install Ruby on Rails on macOS 10
- Overview
- Installing the Windows Subsystem for Linux
- Installing Ruby
- Configuring Git
- Installing Rails
- Setting Up MySQL
- Setting Up PostgreSQL
- Final Steps
Installing Ruby
With package managers or third-party tools, you have plenty of options to install and manage Ruby.
You may already have Ruby installed on your computer. You can check inside a terminal emulator by typing:
This should output some information on the installed Ruby version.
Choose Your Installation Method
There are several ways to install Ruby:
- On a UNIX-like operating system, using your system’s package manager is easiest. However, the packaged Ruby version may not be the newest one.
- Installers can be used to install a specific or multiple Ruby versions. There is also an installer for Windows.
- Managers help you to switch between multiple Ruby versions on your system.
- Finally, you can also build Ruby from source.
On Windows 10, you can also use the Windows Subsystem for Linux to install one of the supported Linux distributions and use any of the installation methods available on that system.
Here are available installation methods:
Package Management Systems
If you cannot compile your own Ruby, and you do not want to use a third-party tool, you can use your system’s package manager to install Ruby.
Some members of the Ruby community feel that you should avoid package managers to install Ruby and that you should use dedicated tools instead.
It is possible that major package managers will install older Ruby versions instead of the latest release. To use the latest Ruby release, check that the package name matches its version number. Or use a dedicated installer.
apt (Debian or Ubuntu)
Debian GNU/Linux and Ubuntu use the apt package manager. You can use it like this:
yum (CentOS, Fedora, or RHEL)
CentOS, Fedora, and RHEL use the yum package manager. You can use it like this:
The installed version is typically the latest version of Ruby available at the release time of the specific distribution version.
snap (Ubuntu or other Linux distributions)
Snap is a package manager developed by Canonical. It is available out-of-the-box on Ubuntu, but snap also works on many other Linux distributions. You can use it like this:
We have several channels per Ruby minor series. For instance, the following commands switch to Ruby 2.3:
portage (Gentoo)
Gentoo uses the portage package manager.
To install a specific version, set RUBY_TARGETS in your make.conf . See the Gentoo Ruby Project website for details.
pacman (Arch Linux)
Arch Linux uses a package manager named pacman. To get Ruby, just do this:
This should install the latest stable Ruby version.
Homebrew (macOS)
Ruby versions 2.0 and above are included by default in macOS releases since at least El Capitan (10.11).
Homebrew is a commonly used package manager on macOS. Installing Ruby using Homebrew is easy:
This should install the latest Ruby version.
FreeBSD
FreeBSD offers both pre-packaged and source-based methods to install Ruby. Prebuilt packages can be installed via the pkg tool:
A source-based method can be used to install Ruby using the Ports Collection. This is useful if you want to customize the build configuration options.
More information about Ruby and its surrounding ecosystem on FreeBSD can be found on the FreeBSD Ruby Project website.
OpenBSD
OpenBSD as well as its distribution adJ has packages for the three major versions of Ruby. The following command allows you to see the available versions and to install one:
You can install multiple major versions side by side, because their binaries have different names (e.g. ruby27 , ruby26 ).
The HEAD branch of the OpenBSD ports collection might have the most recent version of Ruby for this platform some days after it is released, see directory lang/ruby in the most recent ports collection.
Ruby on OpenIndiana
To install Ruby on OpenIndiana, please use the Image Packaging System (IPS) client. This will install the Ruby binaries and RubyGems directly from the OpenIndiana repositories. It’s easy:
However, the third-party tools might be a good way to obtain the latest version of Ruby.
Other Distributions
On other systems, you can search the package repository of your Linux distribution’s manager for Ruby. Alternatively, you can use a third-party installer.
Installers
If the version of Ruby provided by your system or package manager is out of date, a newer one can be installed using a third-party installer.
Some installers allow you to install multiple versions on the same system; associated managers can help to switch between the different Rubies.
If you are planning to use RVM as a version manager you don’t need a separate installer, it comes with its own.
ruby-build
ruby-build is a plugin for rbenv that allows you to compile and install different versions of Ruby. ruby-build can also be used as a standalone program without rbenv. It is available for macOS, Linux, and other UNIX-like operating systems.
ruby-install
ruby-install allows you to compile and install different versions of Ruby into arbitrary directories. chruby is a complimentary tool used to switch between Ruby versions. It is available for macOS, Linux, and other UNIX-like operating systems.
RubyInstaller
On Windows, RubyInstaller gives you everything you need to set up a full Ruby development environment.
Just download it, run it, and you are done!
Ruby Stack
If you are installing Ruby in order to use Ruby on Rails, you can use the following installer:
- Bitnami Ruby Stack provides a complete development environment for Rails. It supports macOS, Linux, Windows, virtual machines, and cloud images.
Managers
Many Rubyists use Ruby managers to manage multiple Rubies. They allow easy or even automatic switching between Ruby versions depending on the project and other advantages but are not officially supported. You can however find support within their respective communities.
asdf-vm
asdf-vm is an extendable version manager that can manage multiple language runtime versions on a per-project basis. You will need the asdf-ruby plugin (which in turn uses ruby-build) to install Ruby.
chruby
chruby allows you to switch between multiple Rubies. It can manage Rubies installed by ruby-install or even built from source.
rbenv
rbenv allows you to manage multiple installations of Ruby. While it can’t install Ruby by default, its ruby-build plugin can. Both tools are available for macOS, Linux, or other UNIX-like operating systems.
RVM (“Ruby Version Manager”)
RVM allows you to install and manage multiple installations of Ruby on your system. It can also manage different gemsets. It is available for macOS, Linux, or other UNIX-like operating systems.
Uru is a lightweight, multi-platform command line tool that helps you to use multiple Rubies on macOS, Linux, or Windows systems.
Building from Source
Of course, you can install Ruby from source. Download and unpack a tarball, then just do this:
By default, this will install Ruby into /usr/local . To change, pass the —prefix=DIR option to the ./configure script.
You can find more information about building from source in the Ruby README file.
Using the third-party tools or package managers might be a better idea, though, because the installed Ruby won’t be managed by any tools.
💊 How To Install #RubyonRails 💊 on Windows 7/8/10 → Complete Tutorial 2019 (May 2020)
Step-By-Step Tutorial on How To Install Ruby, Rails, RubyGems, Git, RMagick, MYSQL2 & SQLite3 on Windows…
Article revised on 📆 May 2020 📆 to reflect the new update
of RubyInstaller2 (Devkit no longer required), Rails 6.0.3 & SQLite3 1.4.0.
Overview
To develop Rails on Windows, you require the following components:
These are all freely available, and are required for any OS Ruby install ↴
📝 Note from the author (May 2020)
As far as I am aware, this is the ONLY Ruby/Rails on Windows tutorial which doesn’t require the installation of Bash. The bash dependency is around 215mb+ of unnecessary data, not worth it.
This tutorial explains the most space-efficient way of installing a pre-compiled version of Ruby, which only requires around 5mb of data + your bundles.
If you have any questions, please either leave a response here, or contact me directly at rpeck@frontlineutilities.co.uk.
On Windows, you need a pre-compiled version of Ruby.
On Linux, you can compile from source. Not Windows.
Well, actually you can. But it requires MASSIVE amounts of patience in order to get the correct dependencies / libraries installed.
The best thing to do is download a pre-built version of Ruby.
⚠️ RailsInstaller does *NOT* keep libraries up to date . ⚠️
💾 Download RubyInstaller (IMPORTANT)
The best thing to do is to download the ZIP version of RubyInstaller. Whilst there is an installer, it’s better to just download the binaries in the ZIP.
If you do want to do this, there are several options:
- Ruby 2.3.x (not worth bothering with)
- Ruby 2.4.x
- Ruby 2.5.x
- Ruby 2.6.x
Due to different build requirements, Ruby 2.4.x started using RubyInstaller2
(which uses MSYS2 over DevKit):
I would personally recommend downloading Ruby 2.5.x (the latest), but if you have an application designed for Ruby 2.4.x you’re also able to use that:
1️⃣ Identify Windows Architecture
The first step is to know your Windows version ( x64 or x86 ):
- Press Windows + R keys on the keyboard
- Type dxdiag and press OK
- Identify the System Type from the list:
Установка Ruby On Rails на Windows Server
Инструкция по установке фреймворка Ruby On Rails на сервер под управлением операционной системы семейства Windows.
Что это такое?
Ruby on Rails — это фреймворк с открытым исходным кодом, написанный на языке программирования Ruby. Обычно Ruby on Rails используется для запуска приложений под ОС Linux, но иногда бывает крайне необходимо запустить приложение на Windows. Для этих целей созданы специальный установщики, например railsinstaller или rubyinstaller.
Загрузка и установка
Для начала необходимо загрузить удобный установщик от Engine Yard.
Запустите загруженный файл для начала процесса установки. Примите лицензионное соглашение.
Выберет каталог для установки фреймворка и необходимых зависимостей. Отметьте с помощью галочек установку всех дополнительных пакетов.
Начнется процесс установки.
После установки перейдите к конфигурации окружения, для этого отметьте галочкой «Configure git and ssh …».
Для конфигурации Git введите пользовательское имя и ваш почтовый адрес.
В итоге для вас будет cгенерирован публичный и приватный ключи.
Настройка
Для того, чтобы выполнить настройку и запустить rails-сервер, откройте консоль Comand Prompt with Ruby and Rails, которую можно найти в меню Win. Выполните установку gem-файла Rails:
gem install rails
Примечание: gem — пакетный менеджер.
Перейдите в каталог тестового проекта:
С помощью следующей команды установите зависимости объявленные в файле Gemfile:
Выполните миграцию базы данных:
bundle exec rake db:migrate RAILS_ENV=development
Выполните запуска Rails-сервера:
Перейдите в браузере по следующему адресу:
http://localhost:3000/
Если все настроено корректно, то вы увидите следующее окно.
All guides / Install Ruby on Rails on macOS 10
A guide to setting up a Ruby on Rails development environment
Operating System
Version
Overview
This will take about 45 minutes.
We will be setting up a Ruby on Rails development environment on Windows 10.
The reason we’re going to be using Bash on Ubuntu on Windows because it allows you to run Linux on your Windows machine. Most Ruby on Rails tutorials and dependencies work best on Linux, so this allows you to get the best of both worlds. A Windows machine for your day to day work, and a Linux subsystem for Ruby on Rails development.
This only works on 64-bit installations of Windows. This is also in beta, so this won’t be nearly as robust as running a Linux virtual machine, but it can definitely do the basics well enough.
Installing the Windows Subsystem for Linux
Windows 10 allows you to run various Linux operating systems inside of Windows similar to a virtual machine, but natively implemented. We’ll use this to install Ruby and run our Rails apps.
Open Powershell as Administrator and run:
Now open Ubuntu in the Start menu or by running wsl in PowerShell or the command prompt. You’ll be asked to setup a new user for Ubuntu. Remember this password as it’s what you’ll use later on when installing packages with sudo .
Congrats! You’ve now got a Ubuntu terminal on Windows. You’ll use this to run your Rails server and other processes for development.
Installing Ruby
Choose the version of Ruby you want to install:
The first step is to install some dependencies for Ruby.
Next we’re going to be installing Ruby using one of three methods. Each have their own benefits, most people prefer using rbenv these days, but if you’re familiar with rvm you can follow those steps as well. I’ve included instructions for installing from source as well, but in general, you’ll want to choose either rbenv or rvm.
Choose one method. Some of these conflict with each other, so choose the one that sounds the most interesting to you, or go with my suggestion, rbenv.
Installing with rbenv is a simple two step process. First you install rbenv , and then ruby-build :
The installation for rvm is pretty simple:
Arguably the least useful Ruby setup for development is installing from source, but I thought I’d give you the steps anyways:
The last step is to install Bundler
rbenv users need to run rbenv rehash after installing bundler.
Configuring Git
We’ll be using Git for our version control system so we’re going to set it up to match our Github account. If you don’t already have a Github account, make sure to register. It will come in handy for the future.
Replace my name and email address in the following steps with the ones you used for your Github account.
The next step is to take the newly generated SSH key and add it to your Github account. You want to copy and paste the output of the following command and paste it here.
Once you’ve done this, you can check and see if it worked:
You should get a message like this:
Installing Rails
Choose the version of Rails you want to install:
Since Rails ships with so many dependencies these days, we’re going to need to install a Javascript runtime like NodeJS and a package manager called Yarn.
To install NodeJS and Yarn, we’re going to add it using the official repository:
And now, without further adieu:
If you’re using rbenv, you’ll need to run the following command to make the rails executable available:
Now that you’ve installed Rails, you can run the rails -v command to make sure you have everything installed correctly:
If you get a different result for some reason, it means your environment may not be setup properly.
Setting Up MySQL
Rails ships with sqlite3 as the default database. Chances are you won’t want to use it because it’s stored as a simple file on disk. You’ll probably want something more robust like MySQL or PostgreSQL.
There is a lot of documentation on both, so you can just pick one that seems like you’ll be more comfortable with.
If you’re new to Ruby on Rails or databases in general, I strongly recommend setting up PostgreSQL.
If you’re coming from PHP, you may already be familiar with MySQL.
You can install MySQL server and client from the packages in the Ubuntu repository. As part of the installation process, you’ll set the password for the root user. This information will go into your Rails app’s database.yml file in the future.
Installing the libmysqlclient-dev gives you the necessary files to compile the mysql2 gem which is what Rails will use to connect to MySQL when you setup your Rails app.
When you’re finished, you can skip to the Final Steps.
Setting Up PostgreSQL
The easiest way to setup PostgreSQL is to install it on Windows using one of the Windows installers. You’ll be able to run it in Windows and connect to it through Linux.
Pay attention to the username and password you setup during installation of Postgres as you will use this to configure your Rails applications later to login to Postgres when your Rails app runs.
You’ll also need to install the development headers on Ubuntu so you can install the pg gem.
Final Steps
The best place to develop Rails apps on the Windows Subsystem for Linux is to navigate to `/mnt/c`. This is actually the C: drive on Windows and it lets you use Sublime, Atom, VS Code, etc on Windows to edit your Rails application.
And now for the moment of truth. Let’s create your first Rails application:
You can now visit http://localhost:3000 to view your new website!
Now that you’ve got your machine setup, it’s time to start building some Rails applications!
If you received an error that said Access denied for user ‘root’@’localhost’ (using password: NO) then you need to update your config/database.yml file to match the database username and password.
To edit your code in Windows: open up Sublime, Atom, VS Code, or whatever editor your prefer and point them to your folders in C:\code and you’ll be able to safely edit your Rails apps in Windows and run them in Linux!
When you create a new Rails app, you might run into the following error: parent directory is world writable but not sticky.
If you run into this issue, you can run chmod +t -R
/.bundle and that should fix the permissions errors and let you finish the bundle install for your Rails app.
That’s it! Let us know in the comments below if you run into any issues or have any other protips to share!.