banner



How To Install Ruby On Windows 8

πŸ’Š How To Install #RubyonRails πŸ’Š on Windows vii/8/10/11 β†’ Tutorial 2022

πŸ’Ž Ruby 3.0+ Running On πŸ’» Windows 11 (08/01/2022)

Article revised on πŸ“† Jan 2022 πŸ“† to reflect the new update
of RubyInstaller2 (Devkit no longer required), Track 6.0.3 & SQLite3 1.iv.0.

Overview

To develop Rails on Windows, y'all require the following components:

  1. πŸ’ŽCerise
  2. πŸ”¨ Build Tools (used for precious stone compilation)
  3. πŸ“‹ RubyGems
  4. πŸš€ Rail
  5. 🚦 GIT
  6. πŸ’» IDE (Code Editor)

These are all freely bachelor, and are required for any OS Ruby install ↴

β€”

πŸ“ Annotation from the writer (Jan 2022)

Every bit far equally I am enlightened, this is the But Ruby/Track on Windows tutorial which doesn't crave the installation of Bash. The bash dependency is around 215mb+ of unnecessary information, not worth information technology.

This tutorial explains the most space-efficient way of installing a pre-compiled version of Ruby, which but requires effectually 5mb of data + your bundles.

β€”

If yous accept whatever questions, please either leave a response here, or contact me directly at rpeck@frontlineutilities.co.uk.

πŸ’ŽRubyπŸ’Ž

On Windows, you need a pre-compiled version of Cerise.

On Linux, you can compile from source. Non Windows.

Well, really you can. But it requires MASSIVE amounts of patience in order to get the correct dependencies / libraries installed.

The best affair to do is download a pre-congenital version of Ruby.

This can exist washed with two packages β†’ RailsInstaller / RubyInstaller:

Don't utilize RailsInstaller…

You should **Not** apply RailsInstaller β†’ But RubyInstaller .

⚠️ RailsInstaller does *Not* keep libraries up to date ... ⚠️

RailsInstaller relies on outdated versions of Ruby. Non worth information technology…

β€”

πŸ’Ύ Download RubyInstaller (Important)

The all-time matter to exercise is to download the ZIP version of RubyInstaller. Whilst there is an installer, it'due south better to just download the binaries in the Nothing.

If you do desire to do this, there are several options:

  • Ruby 2.3.x (non worth bothering with)
  • Ruby-red 2.iv.10
  • Red 2.5.x
  • Blood-red 2.half-dozen.x

Due to different build requirements, Blood-red 2.iv.10 started using RubyInstaller2
(which uses MSYS2 over DevKit):

RubyInstaller 2.0 uses MSYS2- which we recommend over DevKit…

I would personally recommend downloading Cherry-red 2.v.x (the latest), but if you have an awarding designed for Ruby 2.four.10 yous're also able to use that:

1️⃣ Place Windows Architecture

The first pace is to know your Windows version (x64 or x86):

  • Press Windows+ R keys on the keyboard
  • Type dxdiag and printing OK
  • Identify the System Type from the list:

2️⃣ Download Nix From RubyInstaller (may need to install 7Zip):

3️⃣ Save The Zip To Your Hard Drive

Save The ZIP File To A Folder On Your Hard Bulldoze

4️⃣ Unzip To PERMANENT Binder:

Unzip To A Folder Without Whatever Spaces (This Is Where Your Ruddy Install Will Reside)

5️⃣ Add together to PATH:

The Windows PATH allows your organisation to load applications be referencing their name. To call ruby from CMD, you'll need to add together it to the PATH var:

β†’ Windows 7

  • Click on First
  • Right-click on Computer β†’ select Properties
  • From the Arrangement dialogue, select Advanced System Settings:

  • Select "Advanced" tab β€” "Surroundings Variables":

  • From here, select the PATH variable from the SYSTEM Variables console, and select Edit:

When the "path" variable setting loads, paste the path to the /bin directory of Carmine into it (keeping the other paths intact). Subsequently this, click "OK" to exit.

β†’ Windows 10

  • Press Windows button (keyboard)
  • Blazon ENV + press Enter ↴

  • Select Environment Variables ↴

  • The post-obit should appear:

  • Side by side, click New to add the bin directory for the new red directory you created (likewise add the devkit bin directory if you've installed that):

This is the Windows ten Version Of The PATH Variable Editor
  • Click OK and go out any CMD instances you take open up.

πŸ”¨ Build Tools πŸ”¨

Adjacent, y'all need to install "build tools".

These are used to compile gems that rely on external libraries
(nokogiri / rmagick / mysql2):

This error means you lot don't take the required library installed for the gem

β€”
*ALL* operating systems require build tools equally extra downloads. They are applications, files and libraries which assistance your system compile gems.

In Ubuntu, you'd install the build-essential bundle:

In Windows, you need to download the tools separately.

How you exercise this is adamant past which version of RubyInstaller you choose. If you used 2.3.x, you lot use Devkit; 2.iv.x + 2.v.ten utilize MSYS2:

β€”

Devkit (≀ 2.3.x) (Good tutorial)

For older versions (up to 2.3.x) of RubyInstaller, you lot need "DevKit" ↴

Ruby 2.4.10 did away with this, and then if yous're planning on using Ruby 2.4.10 or Ruby 2.5.x , you'll be better using MSYS2 directly from their site.

β€”

Zip (≀ ii.3.x But β†’ 2.iv.x/2.5.x NEEDS to apply MSYS2)…

After downloading 1 of the to a higher place files, load the self extracting archive and "unzip" to a temporary directory:

Extract The Files To The Binder Where They Will Permanently Stay

Once consummate, you need to initialize DevKit and bind it to your Ruby installation:

  1. Load up cmd and cd into the RubyGems directory
  2. Type the following: ruby init.rb & press Enter
  3. Side by side, load up the config.yml β€”
  4. Add the directory for your Ruby installation:
            # devkit/config.yml
# ...
#
# Instance:
#
# ---
# - C:/ruby19trunk
# - C:/ruby192dev
#
---
- "C:/Program Files/Ruby200-x64"
  • Next, in cmd you should blazon ruby setup.rb & printing Enter
  • This should bind DevKit to your Reddish installation, allowing information technology to phone call all the libraries.

MSYS2 (STRONGLY Recommended β†’ essential for β‰₯ 2.4x / 2.5.x)

Ruby 2.4.10 / ii.5.x (RubyInstaller2) uses MSYS2 ↴

MSYS2 Is A CLI Toolchain To Download & Install Dependencies (VERY Similar To Apt)

RubyInstaller2 Requires MSYS2 β€” Which has to be installed independently.

Setting up MSYS2 is slightly more involved than DevKit, merely more effective.

The indicate is that both install a series of files or applications which allow
yous to perform build / compilation operations:

  • Download the appropriate version of MSYS2 x86 or x64 :

  • Save the installer to your difficult drive
  • Double-click the installer to become information technology to load:

  • Later on the installer completes, you need to ready pacman
  • Load a new MSYS2 panel and type the following:

            pacman -Sy pacman          

Y'all should see something similar to the following:

Using the above commands, pacman volition be installed and ready to use.

Now, you lot need to install the diverse build dependencies. This used to be
washed from within MSYS2 itself, merely now it's part of the RubyInstaller2 installation process:

  • Open up up CMD
  • Type ridk install
  • The following screen should appear:

Press 3 and Enter.

From here, it should piece of work to install the various components of the MSYS2 evolution toolchain. If this process fails (nosotros had a Windows 8 user where the process hung randomly), you'll want to switch back to MSYS2 and run one of the post-obit commands (installs the build tools manually):

                          pacman -S base-devel mingw-w64-i686-toolchain              #32-fleck
pacman -S base of operations-devel mingw-w64-x86_64-toolchain #64-bit

If this does not work (in Windows 8), y'all should continually resize the MSYS2 window. This is what it took to get it working on a reader'south system.

β€”

Installing C-dependent Gems (Nokogiri / SQLite3 etc)

The RubyInstaller2 repo has a expert tutorial on how to practise this:

⚠️🚨 NOTE Most SQLITE3 🚨⚠️

SQLite3 1.4.0 is currently incompatible with Windows…

If you apply SQLite3 (as nosotros do in development), you'll find the latest version of the gem to be incompatible with Windows.

The respond to this is to install the "mingw-w64-x86_64-dlfcn" package through MSYS2:

This installs the correct parcel, allowing you to run the SQLite3 1.4.0 gem within the Windows environment.

🧢 Yarn/WebPacker

If you desire to install Webpacker (which requires yarn), you lot will need to install the packages which back up it. Whilst MSYS2 supports both yarn & nodejs, we're yet to find a way to brand them work on a base of operations/organization level (they install, merely are non attainable by Rails)…

            pacman -S mingw-w64-x86_64-yarn
pacman -S mingw-w64-x86_64-nodejs

As mentioned, whilst these install, they don't piece of work with Track/Webpacker withal.

Instead, you lot will need to download and install the native packages from the Yarn & NodeJS websites:

πŸ“‹ RubyGems πŸ“‹

Next, you need to install RubyGems.

RubyGems is the repository which stores all the "gems" you tin can install on Ruby. These gems are the "plugins" for the language, providing functionality.

β€”

Equally this is a divide package to Ruby, it has to be installed manually:

To install RubyGems, you lot need to download the Zip and
unzip to a temporary binder:

Save the ZIP to your System

From there, you will need to open cmd.exe and cd into the TEMPORARY folder. Y'all should then blazon ruby setup.rb and RubyGems willinstall:

If successful, you'll exist able to blazon gem -v in a new example of cmd:

πŸš€ Rails πŸš€

With RubyGems installed, you need to install the rail gem:

⚠️🚨 NOTE ABOUT Ruby ii.7.0+ 🚨⚠️

The recent updates in Red 2.7.0 take caused several problems for Rails.

Specifically, the electric current "nokogiri" precious stone is not compatible with > Ruby two.7.0, so installing a "naked" version of Track kicks up an mistake:

Whilst Nokogiri have released a "pre" version of their precious stone (which addresses this problem), it doesn't install and Rails is still unable to install at the "system" level.

To get around this, you need to install Track with the help of the bundler.

The best way I have found (to fix it) is to make sure that Bundler is using the "global" gem repository, and so add the post-obit to your Gemfile:

gem 'nokogiri', '~> 1.xi.0.rc2'

Doing this with Runway in the same Gemfile gets it installed (with the current restrictions). No other style, apart from that, presently.

If yous're using a Red version pre ii.7.0, you should open cmd and type:
gem install runway --no-document

  • You also need bundler considering without information technology, you cannot use a Gemfile
  • You demand rails because that's the framework y'all're using.

Installing Rails as a system-wide jewel will give you the power to telephone call it whenever needed, non just as part of a Rail awarding:

🚦 GIT 🚦

Yous then demand to install GIT.

Git is a source lawmaking management arrangement ( SCM ), basically allowing you to sync your evolution source with production and staging environments.

It has taken over the office of FTP, allowing you to "push" code to "repositories". If this sounds alien, you need to read up on it. It'southward an essential role of modern web evolution β€” especially Track. Github is a very good place to start:

The installation procedure should be performed equally follows:

Deselect any OS integration β€” you don't demand "GIT" commands popping upwards in Windows Explorer

Make sure you lot use GIT from CMD

This ensures line endings are uniform with Windows and Linux etc

Make sure you're using Windows' own CMD window

Ensure you accept all of the above checked

One time installed, y'all should load a new instance of cmd.exe and type the command git β€” version. If it returns a value, the installation was a success:

πŸ’» IDE (Code Editor) πŸ’»

Finally, you need an IDE (Integrated Evolution Surround).

Whist y'all're free to use Notepad to edit lawmaking, the best organization is to apply a dedicated code editor. The former favorite was Sublime Text, however it was
not updated enough and price.

We employ Atom.io from GitHub (free & open source):

You lot can download hither (free).

πŸŽ‰ After this, y'all're able to develop Ruby on Rails on Windows! πŸŽ‰

πŸ“₯ Thanks For Reading! πŸ“₯

If you demand further assistance, please experience costless to enquire below…

Source: https://medium.com/ruby-on-rails-web-application-development/how-to-install-rubyonrails-on-windows-7-8-10-complete-tutorial-2017-fc95720ee059

Posted by: scottancend.blogspot.com

Related Posts

0 Response to "How To Install Ruby On Windows 8"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel