
Rails Development on Windows


Rails Development on Windows: A Complete Setup Guide for 2025
Setting up a Ruby on Rails development environment on Windows has traditionally been challenging, but with Windows Subsystem for Linux (WSL2), you can now enjoy a seamless Linux-like development experience while staying on Windows. This guide will walk you through the complete setup process and help you avoid common pitfalls.
Why WSL2 for Rails Development?
Rails was built with Unix-like systems in mind, and many gems and tools expect a Linux environment. WSL2 provides:
- Full Linux compatibility without the overhead of a virtual machine
- Better performance than traditional Windows Rails setups
- Access to the entire Linux ecosystem of development tools
- Seamless integration with Windows applications like VS Code
Step 1: Setting Up WSL2
Install WSL2
Open PowerShell as Administrator and run:
wsl --install
This command will:
- Enable the required Windows features
- Download and install the latest Linux kernel
- Install Ubuntu as your default Linux distribution
Important: Restart your computer after installation.
Install Windows Terminal
Download Windows Terminal from the Microsoft Store. This modern terminal application provides:
- Multiple tabs and panes
- Better font rendering
- Customizable themes
- Improved copy/paste functionality
Step 2: Setting Up Your Linux Environment
Open your new Ubuntu terminal and update the system:
sudo apt update && sudo apt upgrade -y
Install essential development dependencies:
sudo apt install -y curl gpg build-essential libssl-dev libreadline-dev zlib1g-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev
Step 3: Installing Ruby with rbenv
Using a Ruby version manager like rbenv allows you to easily switch between Ruby versions for different projects.
Install rbenv
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
Install Ruby
# Install the latest stable Ruby version
rbenv install 3.2.0
rbenv global 3.2.0
# Verify installation
ruby -v
Install Rails
gem install rails
rails -v
Step 4: Setting Up Node.js for Frontend Assets
Modern Rails applications often use JavaScript build tools and React components.
Install Node Version Manager (nvm)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
Install Node.js
# Install and use the latest LTS version
nvm install --lts
nvm use --lts
# Optionally install Yarn
npm install -g yarn
Step 5: Database Setup
PostgreSQL (Recommended)
PostgreSQL is the preferred database for most Rails applications in production:
sudo apt install postgresql postgresql-contrib libpq-dev
sudo service postgresql start
sudo -u postgres createuser -s $(whoami)
MySQL (Alternative)
If your project requires MySQL:
sudo apt install mysql-server mysql-client libmysqlclient-dev
Step 6: Code Editor Configuration
VS Code with Remote-WSL
- Install VS Code on Windows
- Install the "Remote - WSL" extension
- Install these helpful extensions:
- Ruby LSP
- ES7+ React/Redux/React-Native snippets
- Prettier - Code formatter
- GitLens
- Auto Rename Tag
Opening Projects in VS Code
From your WSL2 terminal, you can open any project directly in VS Code:
code ~/projects/myapp
Step 7: Git Configuration
Set up your Git identity:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Creating Your First Rails Application
Here's where many developers encounter their first major pitfall.
The File System Problem
ā Don't do this:
cd /mnt/c/Users/YourName/Projects
rails new myapp # This will cause permission errors!
ā Do this instead:
cd ~
mkdir -p projects
cd projects
rails new myapp
Why the Difference Matters
The /mnt/c/
path represents your Windows C: drive mounted in WSL2. When Rails tries to set file permissions on executables (like files in the bin
directory), Windows doesn't support the same permission model as Linux, causing chmod
operations to fail with "Operation not permitted" errors.
Best Practice: Work in the Linux File System
Always create and work on your Rails projects within the WSL2 Linux file system (~/projects/
). You can still access these files from Windows through the \\wsl$\Ubuntu\home\yourusername\projects\
path in File Explorer.
Navigating Your Development Environment
Opening New Terminal Sessions
You have several options for opening WSL2 terminals:
- Windows Terminal: Press
Win + R
, typewt
, press Enter - Direct WSL: Press
Win + R
, typewsl
, press Enter - Start Menu: Search "Ubuntu" and click the app
- VS Code: Use `Ctrl + Shift + `` to open integrated terminal
Quick Navigation Tips
Create aliases for faster navigation:
# Add to ~/.bashrc
echo 'alias projects="cd ~/projects"' >> ~/.bashrc
echo 'alias myapp="cd ~/projects/myapp"' >> ~/.bashrc
source ~/.bashrc
Now you can quickly navigate with simple commands:
projects # Takes you to ~/projects
myapp # Takes you to ~/projects/myapp
Testing Your Setup
Create a new Rails application to verify everything works:
cd ~/projects
rails new testapp --database=postgresql
cd testapp
bundle install
rails server
Visit http://localhost:3000
in your browser to see the Rails welcome page.
For React development:
npx create-react-app my-react-app
cd my-react-app
npm start
Conclusion
With WSL2, Windows has become a legitimate platform for Rails development. The key to success is understanding the file system boundaries and working within the Linux environment while leveraging Windows tools where appropriate.
This setup gives you:
- A native Linux Rails development environment
- Full Windows application compatibility
- Excellent performance and stability
- Easy integration with modern development tools
The learning curve is minimal, but the productivity gains are substantial. Once you're comfortable with this workflow, you'll find Rails development on Windows to be just as smooth as on macOS or Linux.
Happy coding! š