Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Installing Rails on Windows

Ari Misha
Ari Misha
19,323 Points

Issues with Rails up and running on Windows

Im havin issue with installing Rails on my Windows machine. I've Ruby 2.4.1 installed. It keeps throwing me an error saying "ERROR: Failed to build gem native extension". I've also followed all the steps from "Installing Rails development environment on windows" Workshop and it still doesnt work for some reasons. Please Please Please Please help me. :(

4 Answers

Hiya,

You need to be careful with that blanket approach. It may cause issues further down the line. Are you using RailsInstaller?

If so, the problem is caused by the batch files being hard-coded to the path for the Ruby executable. It is coded in something like:

@"C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.2.0\bin\ruby.exe" "C:/Users/emachnic/GitRepos/railsinstaller-windows/stage/Ruby2.2.0/bin/rails" %1 %2 %3 %4 %5 %6 %7 %8 %9

But it needs to be installation-specific and more like:

@"C:\RailsInstaller\Ruby2.2.0\bin\ruby.exe" "C:\RailsInstaller\Ruby2.2.0\bin\rails" %1 %2 %3 %4 %5 %6 %7 %8 %9

It depends where your ruby.exe file is located, obviously.

There are three files affected, rails.bat as you have spotted, bundle.bat and bundler.bat. I think that's it.

Steve.

Hi there,

Can you post the whole output of the attempted install, please?

What have you downloaded which is failing to install? Does entering rails -v in your command prompt/PowerShell give you anything other than an error?

I've had a look about for this error message and it seems to be a path issue. I installed Rails on my Windows box using RailsInstaller and that had a couple of path glitches in it.

I don't have a single fix, I'm afraid, but if you go through the above we may make some progress.

Steve.

Ari Misha
Ari Misha
19,323 Points

Thank you Steve! I've solved the issue but i dunno whether its a temporary issue or not. I pretty much edited my "rails.bat" file with the following code:

@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
ECHO.This version of Ruby has not been built with support for Windows 95/98/Me.
GOTO :EOF
:WinNT
@"%~dp0ruby.exe" "%~dpn0" %*

If you've like something better solution than this one , please do suggest the alternate solution. I'd really appreciate it. Note: I also installed "bundler" and looks like i still need to install other libraries in order to rails to work smoothly on windows. :|

Ari Misha
Ari Misha
19,323 Points

Hiya Steve! I took your advice and it worked so yeah thank you so much. That really was a blanket approach and yes i was using RailsInstaller. (: