ΠΊΠ°ΠΊ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ruby on rails Π½Π° windows 10
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° Ruby on Rails ΠΏΠΎΠ΄ Windows
ΠΠ°ΠΈΠ½ΡΠ΅ΡΠ΅ΡΠΎΠ²Π°Π» ΠΌΠ΅Π½Ρ Rails. ΠΡΠΏΠΈΠ» ΠΏΠ°ΡΡ ΠΊΠ½ΠΈΠ³, ΠΏΡΠΎΡΠΈΡΠ°Π»β¦ Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ ΡΡΠΎΠ±Ρ, Π·Π°ΡΠ΅ΡΠ°Π»ΠΈΡΡ ΡΡΠΊΠΈ ΠΈ ΠΏΡΠΈΡΠ»ΠΎ Π²ΡΠ΅ΠΌΡ ΡΡΠ°Π²ΠΈΡΡ ΡΠ°Π±ΠΆ. Π ΠΏΡΠΈΡΡΡΠΏΠ°ΡΡβ¦ Ρ ΠΎΡΡ Π±Ρ ΠΊ ΡΠΊΡΠΏΠ΅ΡΠΈΠΌΠ΅Π½ΡΠ°ΠΌ.
ΠΠ°Π΄Π°ΡΠ°: ΠΏΠΎΡΡΠ°Π²ΠΈΡΡ Rails ΠΏΠΎΠ΄ Windows 7 (Π½Π΅ ΡΠΏΡΠ°ΡΠΈΠ²Π°ΠΉΡΠ΅ ΠΌΠ΅Π½Ρ ΠΏΠΎΡΠ΅ΠΌΡ) ΠΈ Π·Π°ΠΏΡΡΡΠΈΡΡ ΡΠ΅ΡΠ²Π΅Ρ.
ΠΠΊΠ°Π·Π°Π»ΠΎΡΡ β ΡΡΠΎ ΠΊΠ²Π΅ΡΡ. ΠΠ°ΡΡ ΡΠ΅Π»ΡΠΊΠΎΠ² ΠΌΡΡΡΡ Π½Π΅Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ. ΠΠΎΠ½Π΅ΡΠ½ΠΎ, Π΅ΡΠ»ΠΈ Π½Π΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Railsinstaller, Π½Π° ΡΡΠΎ ΠΌΠ½Π΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ Π½Π°ΠΌΠ΅ΠΊΠ½ΡΠ»ΠΈ Π² ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΡΡ (ΡΠΏΠ°ΡΠΈΠ±ΠΎ, dreamfall).
ΠΠ΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΠΆΠ΅ ΡΠ°ΡΠΎΠ² ΠΌΠΎΠΈΡ ΠΏΠΎΠΈΡΠΊΠΎΠ², Π·Π°Π²Π΅ΡΡΠΈΠ²ΡΠΈΡ ΡΡ ΡΠ°ΠΊΠΈ ΠΏΠΎΠ»Π½ΠΎΠΉ ΠΈ Π±Π΅Π·ΠΎΠ³ΠΎΠ²ΠΎΡΠΎΡΠ½ΠΎΠΉ ΠΈΠ½ΡΡΠ°Π»Π»ΡΡΠΈΠ΅ΠΉ, ΠΏΠΎΠ΄ ΠΊΠ°ΡΠΎΠΌ.
1. Π‘ΡΠ°Π²ΠΈΠΌ Ruby. Π‘ΡΡΠΎΠ³ΠΎ ΠΎΡΡΡΠ΄Π° rubyinstaller.org/downloads. ΠΠ±ΠΎ ΡΡΡ ΠΎΠ½ ΡΠΎΠ±ΡΠ°Π½ ΠΏΠΎΠ΄ gcc MinGW 32, ΠΊΠΎΡΠΎΡΡΠΉ Π±ΡΠ΄Π΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ ΠΈ Π΄Π»Ρ ΡΠ±ΠΎΡΠΊΠΈ ruby-ΠΌΠΎΠ΄ΡΠ»Π΅ΠΉ
1.1 ΠΠ°ΠΌ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΠΈΡΡΡΡ Π²Π΅ΡΡΠΈΡ 187. ΠΠ΅ΡΡΠΈΡ 192 ΡΡΠ΅ΡΠ΅Ρ Π±ΠΎΠ»Π΅Π΅ ΠΌΠΎΡΠ½ΠΎΠ³ΠΎ ΡΠ°ΠΌΠ°Π½ΡΡΠ²Π°, Π½Π° ΠΊΠΎΡΠΎΡΠΎΠ΅ Ρ ΠΌΠ΅Π½Ρ ΠΌΠ°Π½Ρ Π½Π΅ Ρ
Π²Π°ΡΠΈΠ»ΠΎ.
1.2 Π‘ΡΠ°Π²ΠΈΠΌ Development Kit (ΠΎΠ½ Π½Π°ΠΌ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΠΈΡΡΡΡ, ΡΡΠΎΠ±Ρ ΡΠΎΠ±ΡΠ°ΡΡ Rails), ΡΠ°ΡΠΏΠ°ΠΊΠΎΠ²ΡΠ²Π°Ρ ΠΏΡΡΠΌΠΎ ΠΏΠΎΠ²Π΅ΡΡ
ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π° Ruby (Π΅ΡΠ»ΠΈ ΡΡΠ°Π²ΠΈΠ»ΠΈ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ β ΡΡΠΎ C:\Ruby187, Π² Π΄Π°Π»ΡΠ½Π΅ΠΉΡΠ΅ΠΌ ΠΎΠ±Π·ΠΎΠ²Π΅ΠΌ Π΅Π³ΠΎ $Ruby)
1.3 ΠΠΎΠΆΠ½ΠΎ Π·Π°ΠΎΠ΄Π½ΠΎ ΠΈ Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΡ ΠΏΠΎ Ruby ΡΠΊΠ°ΡΠ°ΡΡ
2. ΠΠ°ΠΌ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΠΈΡΡΡΡ SQLite www.sqlite.org. ΠΡΡ ΠΈΠ² c dll-ΠΊΠΎΠΉ ΠΈ def ΡΠ°ΠΉΠ»ΠΎΠΌ ΡΠ°ΡΠΏΠ°ΠΊΠΎΠ²ΡΠ²Π°Π΅ΠΌ ΠΏΡΡΠΌΠΎ Π² ΠΊΠ°ΡΠ°Π»ΠΎΠ³ $Ruby\bin. ΠΡΠΎ ΠΊΡΡΠ°ΡΠΈ Π±ΡΠ» ΠΏΠ΅ΡΠ²ΡΠΉ ΡΡΡΠΏΡΠΈΠ· (ΡΠ°Π½ΡΡΠ΅ RDBMS Β«ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡΒ» Π±ΡΠ» mySQL)
3. ΠΠ°ΠΏΡΡΠΊΠ°Π΅ΠΌ Comand Prompt wiht Ruby (Π²Ρ Π½Π°ΠΉΠ΄Π΅ΡΠ΅ Π΅Π³ΠΎ Π² start-ΠΌΠ΅Π½Ρ windows)
ΠΡΠΎΠ΄ΠΎΠ»ΠΆΠ΅Π½ΠΈΠ΅ Π²ΠΎΡΠΏΠΎΡΠ»Π΅Π΄ΡΠ΅Ρ, Π΅ΡΠ»ΠΈ ΠΏΠΎ ΠΌΠ΅ΡΠ΅ ΡΠ³Π»ΡΠ±Π»Π΅Π½ΠΈΡ ΠΎΠ±Π½Π°ΡΡΠΆΠ°ΡΡΡ Π΅ΡΠ΅ ΠΏΠΎΠ΄Π²ΠΎΠ΄Π½ΡΠ΅ ΠΊΠ°ΠΌΠ½ΠΈ.
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:
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.
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:
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.
/.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!.
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° Ruby
ΠΡ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΠ°Π·Π»ΠΈΡΠ½ΡΠ΅ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ Π΄Π»Ρ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Ruby. ΠΡΠ° ΡΡΡΠ°Π½ΠΈΡΠ° ΠΎΠΏΠΈΡΡΠ²Π°Π΅Ρ, ΠΊΠ°ΠΊ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΎΡΠ½ΠΎΠ²Π½ΡΠ΅ ΡΠΈΡΡΠ΅ΠΌΡ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΠΏΠ°ΠΊΠ΅ΡΠ°ΠΌΠΈ ΠΈ ΡΡΠΎΡΠΎΠ½Π½ΠΈΠ΅ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ Π΄Π»Ρ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΠΈ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Ruby, ΠΈ ΠΊΠ°ΠΊ ΡΠΎΠ±ΡΠ°ΡΡ Ruby ΠΈΠ· ΠΈΡΡ ΠΎΠ΄Π½ΠΈΠΊΠΎΠ².
ΠΡΠ±Π΅ΡΠΈΡΠ΅ Π²Π°Ρ ΠΌΠ΅ΡΠΎΠ΄ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ
ΠΡΡΡ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΠΏΠΎΡΠΎΠ±ΠΎΠ² ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Ruby:
Π ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΌ ΡΠΏΠΈΡΠΊΠ΅ ΠΏΠ΅ΡΠ΅ΡΠΈΡΠ»Π΅Π½Ρ Π΄ΠΎΡΡΡΠΏΠ½ΡΠ΅ ΡΠΏΠΎΡΠΎΠ±Ρ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Π΄Π»Ρ ΡΠ°Π·Π»ΠΈΡΠ½ΡΡ Π½ΡΠΆΠ΄ ΠΈ ΠΏΠ»Π°ΡΡΠΎΡΠΌ.
Π‘ΠΈΡΡΠ΅ΠΌΡ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΠΏΠ°ΠΊΠ΅ΡΠ°ΠΌΠΈ
ΠΡΠ»ΠΈ Π²Ρ Π½Π΅ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ Π²Π°Ρ ΡΠΎΠ±ΡΡΠ²Π΅Π½Π½ΡΠΉ Ruby ΠΈ Π½Π΅ Ρ ΠΎΡΠΈΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΡΠΎΡΠΎΠ½Π½ΠΈΠΉ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½Ρ Π΄Π»Ρ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ β Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ ΠΏΠ°ΠΊΠ΅ΡΠ½ΡΠΌ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅ΡΠΎΠΌ Π²Π°ΡΠ΅ΠΉ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΡ.
ΠΠ΅ΠΊΠΎΡΠΎΡΡΠ΅ ΡΡΠ°ΡΡΠ½ΠΈΠΊΠΈ ΡΠΎΠΎΠ±ΡΠ΅ΡΡΠ²Π° Ruby ΡΠ±Π΅ΠΆΠ΄Π΅Π½Ρ, ΡΡΠΎ Π½ΠΈΠΊΠΎΠ³Π΄Π° Π½Π΅ ΡΡΠΎΠΈΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ ΠΏΠ°ΠΊΠ΅ΡΠ½ΡΠΌΠΈ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅ΡΠ°ΠΌΠΈ Π΄Π»Ρ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Ruby. ΠΠΌΠ΅ΡΡΠΎ ΡΡΠΎΠ³ΠΎ Π»ΡΡΡΠ΅ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ Π΄ΡΡΠ³ΠΈΠΌΠΈ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠ°ΠΌΠΈ. ΠΡΡΠ°Π²ΠΈΠΌ Π²ΡΠ΅ ΠΏΠ»ΡΡΡ ΠΈ ΠΌΠΈΠ½ΡΡΡ Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΠΏΠΎΠ΄Ρ ΠΎΠ΄Π° Π·Π° Π³ΡΠ°Π½ΠΈΡΠ°ΠΌΠΈ Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΡΠ΅ΠΊΡΡΠ°, ΠΎΡΠΌΠ΅ΡΠΈΠΌ Π»ΠΈΡΡ, ΡΡΠΎ ΠΎΡΠ½ΠΎΠ²Π½ΠΎΠΉ ΠΏΡΠΈΡΠΈΠ½ΠΎΠΉ Π΄Π°Π½Π½ΠΎΠΉ ΡΠ±Π΅ΠΆΠ΄Π΅Π½Π½ΠΎΡΡΠΈ ΡΠ²Π»ΡΠ΅ΡΡΡ ΡΠΎ, ΡΡΠΎ Π² ΠΏΠ°ΠΊΠ΅ΡΠ½ΡΡ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅ΡΠ°Ρ Π·Π°ΡΠ°ΡΡΡΡ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡΡΡ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎΠ± ΡΡΡΠ°ΡΠ΅Π²ΡΠΈΡ Π²Π΅ΡΡΠΈΡΡ Ruby. ΠΡΠ»ΠΈ Π²Ρ Ρ ΠΎΡΠΈΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π½ΠΎΠ²Π΅ΠΉΡΡΡ Π²Π΅ΡΡΠΈΡ Ruby, ΡΠ±Π΅Π΄ΠΈΡΠ΅ΡΡ, ΡΡΠΎ Π²Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΠ΅ Π²Π΅ΡΠ½ΠΎΠ΅ ΠΈΠΌΡ ΠΏΠ°ΠΊΠ΅ΡΠ° ΠΈΠ»ΠΈ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΡΠΉΡΠ΅ΡΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠ°ΠΌΠΈ ΠΎΠΏΠΈΡΠ°Π½Π½ΡΠΌΠΈ Π½ΠΈΠΆΠ΅ Π²ΠΌΠ΅ΡΡΠΎ ΡΡΠΎΠ³ΠΎ.
apt (Debian ΠΈΠ»ΠΈ Ubuntu)
ΠΠ°ΠΊΠ΅Ρ ruby-full ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡ Ruby Π²Π΅ΡΡΠΈΠΈ 2.3.1, ΠΊΠΎΡΠΎΡΠ°Ρ ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΠΌ ΡΡΠ°Π±ΠΈΠ»ΡΠ½ΡΠΌ ΡΠ΅Π»ΠΈΠ·ΠΎΠΌ.
yum (CentOS, Fedora, ΠΈΠ»ΠΈ RHEL)
Π£ΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΠΌΠ°Ρ Π²Π΅ΡΡΠΈΡ ΠΎΠ±ΡΡΠ½ΠΎ ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅ΠΉ Π²Π΅ΡΡΠΈΠ΅ΠΉ Ruby, Π΄ΠΎΡΡΡΠΏΠ½ΠΎΠΉ Π½Π° ΠΌΠΎΠΌΠ΅Π½Ρ Π²ΡΡ ΠΎΠ΄Π° ΠΊΠΎΠ½ΠΊΡΠ΅ΡΠ½ΠΎΠΉ Π²Π΅ΡΡΠΈΠΈ Π΄ΠΈΡΡΡΠΈΠ±ΡΡΠΈΠ²Π°.
portage (Gentoo)
pacman (Arch Linux)
ΠΡΠΎ Π΄ΠΎΠ»ΠΆΠ½ΠΎ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΠΏΠΎΡΠ»Π΅Π΄Π½ΡΡ ΡΡΠ°Π±ΠΈΠ»ΡΠ½ΡΡ Π²Π΅ΡΡΠΈΡ Ruby.
Homebrew (macOS)
ΠΠ° OS X El Capitan, Yosemite ΠΈ Mavericks, Ruby 2.0 ΡΠΆΠ΅ Π²ΠΊΠ»ΡΡΠ΅Π½Ρ. OS X Mountain Lion, Lion ΠΈ Snow Leopard ΠΏΠΎΡΡΠ°Π²Π»ΡΡΡΡΡ Ρ Π²Π΅ΡΡΠΈΠ΅ΠΉ Ruby 1.8.7.
ΠΠ½ΠΎΠ³ΠΈΠ΅ Π»ΡΠ΄ΠΈ Π½Π° macOS ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡΡ Homebrew ΠΊΠ°ΠΊ ΠΏΠ°ΠΊΠ΅ΡΠ½ΡΠΉ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ. Π ΡΡΠΎ Π΄Π΅ΠΉΡΡΠ²ΠΈΡΠ΅Π»ΡΠ½ΠΎ ΠΏΡΠΎΡΡΠΎ β ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ Ruby:
ΠΡΠΎ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡ ΠΏΠΎΡΠ»Π΅Π΄Π½ΡΡ Π²Π΅ΡΡΠΈΡ Ruby.
OpenBSD
OpenBSD, Π° ΡΠ°ΠΊΠΆΠ΅ Π΅Π³ΠΎ Π΄ΠΈΡΡΡΠΈΠ±ΡΡΠΈΠ² adJ, ΠΈΠΌΠ΅Π΅Ρ ΠΏΠ°ΠΊΠ΅ΡΡ Π΄Π»Ρ ΡΡΠ΅Ρ ΠΎΡΠ½ΠΎΠ²Π½ΡΡ Π²Π΅ΡΡΠΈΠΉ Ruby. Π‘Π»Π΅Π΄ΡΡΡΠ°Ρ ΠΊΠΎΠΌΠ°Π½Π΄Π° ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π²Π°ΠΌ ΡΠ²ΠΈΠ΄Π΅ΡΡ Π΄ΠΎΡΡΡΠΏΠ½ΡΠ΅ Π²Π΅ΡΡΠΈΠΈ ΠΈ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΠΎΠ΄Π½Ρ ΠΈΠ· Π½ΠΈΡ :
ΠΠ΅ΡΠΊΠ° HEAD ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΠΈ ΠΏΠΎΡΡΠΎΠ² OpenBSD ΠΌΠΎΠΆΠ΅Ρ ΠΈΠΌΠ΅ΡΡ ΡΠ°ΠΌΡΡ ΠΏΠΎΡΠ»Π΅Π΄Π½ΡΡ Π²Π΅ΡΡΠΈΡ Ruby Π΄Π»Ρ ΡΡΠΎΠΉ ΠΏΠ»Π°ΡΡΠΎΡΠΌΡ ΡΠ΅ΡΠ΅Π· Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ Π΄Π½Π΅ΠΉ ΠΏΠΎΡΠ»Π΅ Π΅Π΅ ΡΠ΅Π»ΠΈΠ·Π°, ΡΠΌΠΎΡΡΠΈΡΠ΅ Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΡ lang/ruby Π² ΡΠ°ΠΌΠΎΠΉ ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅ΠΉ ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΠΈ ΠΏΠΎΡΡΠΎΠ².
Ruby Π½Π° Solaris ΠΈ OpenIndiana
Ruby 1.8.7 Π΄ΠΎΡΡΡΠΏΠ΅Π½ Π΄Π»Ρ Solaris 8-10 Π½Π° Sunfreeware ΠΈ Blastwave. Ruby 1.9.2p0 ΡΠ°ΠΊΠΆΠ΅ Π΄ΠΎΡΡΡΠΏΠ΅Π½ Π½Π° Sunfreeware, Π½ΠΎ ΡΡΠΎ Π²ΡΠ΅ ΡΠΆΠ΅ ΡΡΡΠ°ΡΠ΅Π»ΠΎ.
Π§ΡΠΎΠ±Ρ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ Ruby Π½Π° OpenIndiana, ΠΏΠΎΠΆΠ°Π»ΡΠΉΡΡΠ°, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠΉΡΠ΅ ΠΊΠ»ΠΈΠ΅Π½Ρ Image Packaging System, ΠΈΠ»ΠΈ IPS. ΠΡΠΎ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡ ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΠ΅ Π±ΠΈΠ½Π°ΡΠ½ΠΈΠΊΠΈ Ruby ΠΈ RubyGems ΠΏΡΡΠΌΠΎ ΠΈΠ· ΡΠ΅ΡΠ΅Π²ΠΎΠ³ΠΎ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ OpenSolaris Π΄Π»Ρ Ruby 1.9. ΠΡΠΎ ΠΏΡΠΎΡΡΠΎ:
ΠΠ΄Π½Π°ΠΊΠΎ, ΡΡΠΎΡΠΎΠ½Π½ΠΈΠ΅ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ Ρ ΠΎΡΠΎΡΠΈΠΌ ΡΠΏΠΎΡΠΎΠ±ΠΎΠΌ ΠΏΠΎΠ»ΡΡΠΈΡΡ ΠΏΠΎΡΠ»Π΅Π΄Π½ΡΡ Π²Π΅ΡΡΠΈΡ Ruby.
ΠΡΡΠ³ΠΈΠ΅ Π΄ΠΈΡΡΡΠΈΠ±ΡΡΠΈΠ²Ρ
ΠΠ° Π΄ΡΡΠ³ΠΈΡ ΡΠΈΡΡΠ΅ΠΌΠ°Ρ , Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΏΠΎΠΈΡΠΊΠ°ΡΡ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ ΠΏΠ°ΠΊΠ΅ΡΠ° Ruby Π΄Π»Ρ ΠΏΠ°ΠΊΠ΅ΡΠ½ΠΎΠ³ΠΎ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅ΡΠ° Π²Π°ΡΠ΅Π³ΠΎ Linux Π΄ΠΈΡΡΡΠΈΠ±ΡΡΠΈΠ²Π°, ΠΈΠ»ΠΈ ΠΆΠ΅ ΡΡΠΎΡΠΎΠ½Π½ΠΈΠ΅ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ ΠΌΠΎΠ³ΡΡ ΡΡΠ°ΡΡ Ρ ΠΎΡΠΎΡΠΈΠΌ Π²ΡΠ±ΠΎΡΠΎΠΌ Π΄Π»Ρ Π²Π°Ρ.
Π£ΡΡΠ°Π½ΠΎΠ²ΡΠΈΠΊΠΈ
ruby-build
ruby-install
ruby-install ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π²Π°ΠΌ ΡΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡΠΎΠ²Π°ΡΡ ΠΈ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΡΠ°Π·Π»ΠΈΡΠ½ΡΠ΅ Π²Π΅ΡΡΠΈΠΈ Ruby Π² ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ»ΡΠ½ΡΠ΅ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΈ. Π‘ΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ ΡΠ°ΠΊΠΆΠ΅ ΡΠΎΠ΄ΡΡΠ²Π΅Π½Π½ΠΈΠΊ chruby, ΠΊΠΎΡΠΎΡΡΠΉ ΡΠΏΡΠ°Π²Π»ΡΠ΅Ρ ΠΏΠ΅ΡΠ΅ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ΠΌ ΠΌΠ΅ΠΆΠ΄Ρ Π²Π΅ΡΡΠΈΡΠΌΠΈ Ruby. ΠΠ½ Π΄ΠΎΡΡΡΠΏΠ΅Π½ Π΄Π»Ρ macOS, Linux ΠΈ Π΄ΡΡΠ³ΠΈΡ UNIX-ΠΏΠΎΠ΄ΠΎΠ±Π½ΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΡΡ ΡΠΈΡΡΠ΅ΠΌ.
RubyInstaller
ΠΠ»Ρ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅ΠΉ Windows ΡΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ ΠΎΡΠ»ΠΈΡΠ½ΡΠΉ ΠΏΡΠΎΠ΅ΠΊΡ, ΠΏΠΎΠΌΠΎΠ³Π°ΡΡΠΈΠΉ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ Ruby: RubyInstaller. ΠΠ½ ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²Π»ΡΠ΅Ρ Π²Π°ΠΌ Π²ΡΠ΅, ΡΡΠΎ Π½ΡΠΆΠ½ΠΎ Π΄Π»Ρ Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ ΠΏΠΎΠ»Π½ΠΎΡΠ΅Π½Π½ΠΎΠ³ΠΎ ΠΎΠΊΡΡΠΆΠ΅Π½ΠΈΡ Ruby Π½Π° Windows.
ΠΡΠΎΡΡΠΎ ΡΠΊΠ°ΡΠ°ΠΉΡΠ΅ Π΅Π³ΠΎ, Π·Π°ΠΏΡΡΡΠΈΡΠ΅ ΠΈ Π²ΡΠ΅ Π³ΠΎΡΠΎΠ²ΠΎ!
Ruby Stack
ΠΡΠ»ΠΈ Π²Ρ ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΡΠ΅ Ruby Π΄Π»Ρ ΡΠΎΠ³ΠΎ, ΡΡΠΎΠ±Ρ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ Ruby on Rails, Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ ΡΡΡΠ°Π½ΠΎΠ²ΡΠΈΠΊ:
ΠΠ΅Π½Π΅Π΄ΠΆΠ΅ΡΡ
ΠΠ½ΠΎΠ³ΠΈΠ΅ ΡΡΠ±ΠΈΡΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡΡ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅ΡΡ Π΄Π»Ρ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΠΌΠΈ Π²Π΅ΡΡΠΈΡΠΌΠΈ Ruby. ΠΠ½ΠΈ ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²Π»ΡΡΡ ΡΠ°Π·Π»ΠΈΡΠ½ΡΠ΅ ΠΏΡΠ΅ΠΈΠΌΡΡΠ΅ΡΡΠ²Π°, Π½ΠΎ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°ΡΡΡΡ Π½Π΅ ΠΎΡΠΈΡΠΈΠ°Π»ΡΠ½ΠΎ. ΠΠ΄Π½Π°ΠΊΠΎ ΠΈΡ ΡΠΎΠΎΠ±ΡΠ΅ΡΡΠ²ΠΎ ΠΌΠΎΠΆΠ΅Ρ ΠΎΠΊΠ°Π·Π°ΡΡ ΠΏΠΎΠΌΠΎΡΡ.
asdf-vm
chruby
chruby ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π²Π°ΠΌ ΠΏΠ΅ΡΠ΅ΠΊΠ»ΡΡΠ°ΡΡΡΡ ΠΌΠ΅ΠΆΠ΄Ρ ΡΠ°Π·Π½ΡΠΌΠΈ Π²Π΅ΡΡΠΈΡΠΌΠΈ Ruby. chruby ΠΌΠΎΠΆΠ΅Ρ ΡΠΏΡΠ°Π²Π»ΡΡΡ Π²Π΅ΡΡΠΈΡΠΌΠΈ Ruby, ΠΊΠΎΡΠΎΡΡΠ΅ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Ρ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ruby-install ΠΈΠ»ΠΈ Π΄Π°ΠΆΠ΅ ΡΠΎΠ±ΡΠ°Π½Π½ΡΠΌΠΈ ΠΈΠ· ΠΈΡΡ ΠΎΠ΄Π½ΠΈΠΊΠΎΠ².
rbenv
rbenv ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π²Π°ΠΌ ΡΠΏΡΠ°Π²Π»ΡΡΡ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΠΌΠΈ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Π½ΡΠΌΠΈ Π²Π΅ΡΡΠΈΡΠΌΠΈ Ruby. ΠΠ½ Π½Π΅ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΡ Ruby, Π½ΠΎ Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ ΡΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ ΠΏΠΎΠΏΡΠ»ΡΡΠ½ΡΠΉ ΠΏΠ»Π°Π³ΠΈΠ½ ruby-build. ΠΠ±Π° ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠ° Π΄ΠΎΡΡΡΠΏΠ½Ρ Π΄Π»Ρ macOS, Linux ΠΈ Π΄ΡΡΠ³ΠΈΡ UNIX-ΠΏΠΎΠ΄ΠΎΠ±Π½ΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΡΡ ΡΠΈΡΡΠ΅ΠΌ.
RVM (βRuby Version Managerβ)
RVM ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π²Π°ΠΌ ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°ΡΡ ΠΈ ΡΠΏΡΠ°Π²Π»ΡΡΡ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΠΌΠΈ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Π½ΡΠΌΠΈ Π²Π΅ΡΡΠΈΡΠΌΠΈ Ruby Π² Π²Π°ΡΠ΅ΠΉ ΡΠΈΡΡΠ΅ΠΌΠ΅. Π’Π°ΠΊΠΆΠ΅ ΠΎΠ½ ΠΌΠΎΠΆΠ΅Ρ ΡΠΏΡΠ°Π²Π»ΡΡΡ ΡΠ°Π·Π½ΡΠΌΠΈ Π½Π°Π±ΠΎΡΠ°ΠΌΠΈ Π³Π΅ΠΌΠΎΠ². ΠΠΎΡΡΡΠΏΠ΅Π½ Π΄Π»Ρ macOS, Linux ΠΈ Π΄ΡΡΠ³ΠΈΡ UNIX-ΠΏΠΎΠ΄ΠΎΠ±Π½ΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΡΡ ΡΠΈΡΡΠ΅ΠΌ.
Π‘Π±ΠΎΡΠΊΠ° ΠΈΠ· ΠΈΡΡ ΠΎΠ΄Π½ΠΈΠΊΠΎΠ²
ΠΠΎΠ½Π΅ΡΠ½ΠΎ, Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ Ruby ΠΈΠ· ΠΈΡΡ ΠΎΠ΄Π½ΠΈΠΊΠΎΠ². Π‘ΠΊΠ°ΡΠ°ΠΉΡΠ΅ ΠΈ ΡΠ°ΡΠΏΠ°ΠΊΡΠΉΡΠ΅ Π°ΡΡ ΠΈΠ², Π·Π°ΡΠ΅ΠΌ ΠΏΡΠΎΡΡΠΎ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΠ΅:
ΠΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ ΡΡΠΎΡΠΎΠ½Π½ΠΈΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ² ΠΈΠ»ΠΈ ΠΏΠ°ΠΊΠ΅ΡΠ½ΡΡ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅ΡΠΎΠ² ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ Π»ΡΡΡΠ΅, Ρ ΠΎΡΡ Π±Ρ ΠΏΠΎΡΠΎΠΌΡ, ΡΡΠΎ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Π½ΡΠ΅ Ruby Π½Π΅ Π±ΡΠ΄ΡΡ ΡΠΏΡΠ°Π²Π»ΡΡΡΡΡ Π»ΡΠ±ΡΠΌΠΈ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠ°ΠΌΠΈ.
💊 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.
💾 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:
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 ):
Ruby on Rails on Windows 10 in 2019
If you want to install Ruby on Rails on Windows, look no further! I recommend that you use either Linux or macOS to develop in Rails if you have the option. But sometimes you have no choice. My Macbook has to go back to Apple for repairs so I decided to try developing on Windows. Here is my setup:
Install WSL
You can use Ruby in Windows with Ruby for Windows but if you want to use Rails I recommend that you use WSL. WSL is short for Windows Subsystem for Linux and it creates a Linux environment in Windows. WSL is fully supported by Microsoft so you can get it for free from the Microsoft Store:
But donβt start it after the install finishes. Open a Windows Powershell with Administrator rights.
And copy and paste this line:
Hit βEnterβ and restart your computer.
If you donβt enter the βEnable-WindowsOptionalFeatureβ line you will get the following error and WSL wonβt work:
Install updates and dependencies
Now that you have WSL installed itβs time to start it. The first time it starts you are asked to create a user. Go ahead and create one, make sure you remember the password!
Before we start installing stuff we have to update the Linux packages. Copy and paste this line to update everything:
Tip: you can right-click to paste something in the WSL terminal.
Itβs a good practice to run this line once a month to keep things updated and safe.
Install Ruby and Rails and dependencies
Just a tip: if you hold shift while clicking on the Ubuntu icon you open a second window.
Rails has a lot of dependencies, letβs install them:
Before we can install Rails we need Ruby first. There are many ways to install Ruby:
Letβs go with rbenv because that is the most common way:
and add rbenv to the PATH variable, like it asks for after installation:
Be careful when copy & pasting, sometimes Windows turns single quotes (β) into backticks (`) or other curly quotes.
When rbenv is installed you can use it to install Ruby and activate it. No need for sudo this time.
TIP: Iβve noticed that WSL sometimes seems to hang, usually selecting the window and pressing a random key is enough to activate it again. So when the commands above seem to take a very long time press the spacebar every now and then to make sure itβs still working.
Time to install bundler and then Rails:
You now have an up to date WSL environment with rbenv, ruby 2.5.3 and the latest bundler and rails installed.
Databases
Iβll do a writeup of installing Postgresql in another post. But it basically comes down to two choices:
My recommendation is to use the Windows installer because I ran into some weird problems when trying to use Postgres in WSL. Use the interactive installer, not the Graphical installer by BigSQL.
Some tips and tricks
Ping me on Twitter or email if you need more help. Or look at one of the guides other people have written: