Rails on Windows
August 30, 2020
Setting Up Ruby on Rails on Windows
Setting up Rails on Windows can be a straightforward process with tools like Scoop and msys2
. This guide walks you through the installation of Ruby, Rails, and all necessary dependencies, so you can start developing Rails applications locally on Windows.
Step 1: Installing Ruby with Scoop
First, use Scoop to install ruby
, a simple and efficient package manager for Windows.
scoop install ruby
Once installed, Scoop will prompt you to add the msys2
toolchain, which is essential for managing Windows dependencies.
Step 2: Install msys2
Now, install msys2
using Scoop to ensure your environment has access to crucial build tools.
scoop install msys2
After this step, you’ll have a compatible Ruby environment ready for Rails setup.
Step 3: Setting Up ridk
To further configure msys2
, use the ridk
tool included with Ruby to finalize installation. Run these commands in order:
ridk install
Then enable the environment:
ridk enable
With this, you’re ready to install Rails.
Step 4: Installing Rails
Now you can install Rails using RubyGems:
gem install rails
If all went well, you should now have both ruby
and rails
installed.
Checking Versions
Verify your installation by checking the Ruby and Rails versions:
ruby --version# Expected Output: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x64-mingw32]rails --version# Expected Output: Rails 6.0.3.2
Step 5: Building Your First Rails Application
With Ruby and Rails installed, let’s create a Rails application to confirm everything is working correctly.
- Scaffold a new Rails app by running:
rails new hello-rails
This command generates all the necessary files and installs your app’s dependencies.
- Navigate into the app directory:
cd hello-rails
- Start the Rails server:
rails s
Your Rails application should now be running locally at http://localhost:3000/
. Open this URL in your browser to see the default Rails welcome page.
Further Reading
For a deeper dive into Rails development, check out the [Rails Guides](https://guides.rubyonrails