как установить 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:

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

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…

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

Article revised on 📆 May 2020 📆 to reflect the new update
of RubyInstaller2 (Devkit no longer required), Rails 6.0.3 & SQLite3 1.4.0.

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

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.

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

If you have any questions, please either leave a response here, or contact me directly at rpeck@frontlineutilities.co.uk.

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

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.

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

💾 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):

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

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:

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10But don’t start it after the install finishes. Open a Windows Powershell with Administrator rights.

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

And copy and paste this line:

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

Hit “Enter” and restart your computer.

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

If you don’t enter the “Enable-WindowsOptionalFeature” line you will get the following error and WSL won’t work:

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

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!

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10Before 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.

как установить ruby on rails на windows 10. Смотреть фото как установить ruby on rails на windows 10. Смотреть картинку как установить ruby on rails на windows 10. Картинка про как установить ruby on rails на windows 10. Фото как установить ruby on rails на windows 10

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:

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *