Back to posts

I Installed Ruby and Rails on Windows 11 So You Don't Have To

Mistakes were made, but they provided good lessons in why Rails needs to update its guides for higher adoption.

By Andy Maldonado
Posted: Tue Apr 11 22:16:36 2023


EDIT: Updating this article as of 05/08/23 with some new information

I tried to install Ruby on Rails on Windows 11 and it worked!

Overall, it was harder than it should have been. But with some googling, I figured out how to resolve the main issues and get it set up. Now, let me just say, DON’T DO THIS. Setting up a virtual box is much easier, and setting up both ruby and rails is easier on Linux. rbenv handles ruby version management, and installing rails is as simple as installing a gem. The Odin project has great guides on installing both Ruby and Rails, I’d recommend it!

One of the main reasons not to do it (besides the difficulty) is that most gems are designed for Linux, and thus aren't necessarily going to work with Windows. I won't get into that here, the goal of this was to simply get it working.

Now onto installing Ruby and Rails for Windows.

Installing Ruby was easy, just go to ruby-lang.org and install via the installer. This doesn’t take very long and once you’ve completed it you should have the latest Ruby version on your computer. I'd imagine an issue you'll run into later is updating Ruby and managing versions, but admittedly this was really just a test run and I don't plan on using this beyond the proof of concept. If you do try this, I'd love to hear how it goes!

From there, you’ll notice some new files in your apps list. You can see the Ruby version you installed, as well as Interactive Ruby (aka IRB). This is how you can run simple ruby programs on your Windows computer. If you simply create a .rb file (I personally find this to be easiest in VS Code in the folder you’re creating the file) you can then create a simple method such as:
def hello_world
   return "Hello world!"
end
puts hello_world
#output: "Hello World!"

then run the file via the irb. The easiest way to do this imo is to load the command prompt or PowerShell in the folder where the file is and run irb ./filename (press tab to get the full filename). This will tell the IRB to run it, and you should see "Hello world!".

And you did it! You did something people said should be impossible!

Now onto the hard part, installing Rails to Windows.

First, let me tell you how I failed to do it. My recommended version is based on AFTER I failed, so my adjusted version might not work without the failure first. Hopefully not!

First, I installed Rails via the Rails installer as per the Rails Getting Started guide. This was a huge mistake. EDIT 05/08/23: The Rails installer contains an old version of Ruby and Rails. At first, it seemingly worked! I had Rails, but noticed a few things were off immediately. First, the Rails version was version 7. Rails is on version 7, and I have no reason to use Rails 5. Running bundle install via the command line also caused its own set of issues, specifically, a certificate error:

Uh Oh, SSL issue


Bundler::Fetcher::CertificateFailureError Could not verify the SSL Certificate for https://rubygems.org.

The guide they linked to help you troubleshoot this error is a dead link. How funny is that! Here’s how I handled the certificate issue.

I updated the certificate as per the following guide. Another theory I have is that I wasn't running any of these commands as administrator.

It seemed to have worked in the sense that I could now bundle install, but I kept running into an issue with minitest requiring a higher ruby version. Very strange considering I just installed the latest version minutes ago! Either this certificate setup points to an older ruby version or the Rails installer installed an old version of Ruby onto my system. Once I ran ruby -v, I noticed I was back into the 2016 era, 2.something.

Here's how I handled this error:

I re-installed Ruby and then tried simply updating my bundler and updating Rubygems as follows via the command prompt (PowerShell should work too). I did each command one at a time.
ruby -v

gem install bundler

gem update --system

gem install rails 

This finally updated my rails gem to the proper version. I then created a new Rails app, ran bundle install, and loaded the Rails server via the command prompt (while in the directory for the new app):

ruby bin/rails server

Proof - Windows Ruby on Rails


🎉 Congrats! 🎉 You did the impossible! 🎉

Again, I don’t recommend this, but I think if you avoid using the Rails installer and just install the gem via the command prompt, you can shortcut this process. I’d be interested to see if that works for others, or if I’m just totally wrong.

Overall, I've learned that this is a barrier to accessing Ruby and Rails as well. The Rails installer should be updated to match the latest version, and the guides should be thoroughly tested to help a new user get up and running with Rails quickly. I think the rails guides are very useful, but there's definitely some legacy information in them. Rubygems should update their links as well, as the link to help with the SSL issue is dead. Alternatively, I would drop windows support if it's going to be ignored as such. Regardless, it is possible, so if you're interested in trying Rails now you really don't have an excuse. Happy coding!

EDIT: 05/08/23
I saw a Reddit post where a person was struggling to get Ruby and Rails set up on their Windows system and tried to help them out. They were specifically running into issues setting up Bootstrap. I figured, well, I already have Ruby and Rails on my Windows system, let's try it out! Funnily enough, I ran into an issue immediately. I was getting the same error as the redditor, "The asset "application.css" is not present in the asset pipeline." What was the issue?

Digging deeper into this error, I noticed that esbuild was seemingly installed into my Rails app, despite not having Node or Yarn installed on my Windows system. Installing both of them and then re-running the CSS bundling and JS bundling then allowed esbuild to install and import Bootstrap properly. But again, this is another barrier into the world of Ruby that I think will push developers into more Windows-friendly environments.