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

Error installing rails: nokogiri requires Ruby version < 2.7.dev, >= 2.3.

Hey, I've followed all the steps in the video but when trying to install rails I get this error:

Fetching: nokogiri-1.10.4-x86-mingw32.gem (100%) ERROR: Error installing rails: nokogiri requires Ruby version < 2.7.dev, >= 2.3.

--

I read a couple of fixes on stackoverflow about using different versions of nokogiri but I don't want to run into issues with this tutorial down the line.

Could you please tell me what I should do?

2 Answers

If anyone else has this issue, download this installer:

https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.7-1/rubyinstaller-2.5.7-1-x86.exe

After you have ran the installer, leave the 'Install MYSYS2' ticked and press enter on the next screen to install it all.

After that has been installed, follow the steps in the tutorial as normal but you won't need the devkit because MYSYS2 has it installed already I think.

Hope this helps!

Hi Matt,

What Ruby version are you running? (type ruby -v in the terminal)

The error is saying that your current nokogiri install needs a higher version of Ruby. So, either install a different nokogiri or have multiple installs of Ruby. If you're on Mac/Linux, rvm can help you with that - on Windows, try something like Uru.

Having a different version of Nokogiri won't cause you any problems.

Let me know how you get on.

Steve.

Hey Steve, thanks for your reply! I am following the tutorial so my version is: ruby 2.2.5p319

I'm on Windows and I'm not quite sure how to install a different version of nokogiri since I'm just starting out. Do you know how I could install it?

Should I just put this into the command line?

scoop install https://bitbucket.org/jonforums/uru/downloads/uru.json

I think downgrading Nokogiri is going to be easier than having multiple Ruby versions; I assume you're on Windows?

Can you see the Gemfile and Gemfile.lock files? In those, you want to set the Nokogiri versions. You're currently trying to install 1.10.4. If you change that version to 1.8.2, that is compatible with Ruby 2.2.x

I don't see nokogiri in the gemfile.lock file? Do I need to manually put it in?

And there are multiple gemfiles but none have nokogiri in them - > https://imgur.com/a/mvao3be

I'm really confused lol sorry for being such a noob

No need to apologise!

Where are you up to with the course - have you created a new Rails app yet? If not, then I was wrong to suggest looking at the Gemfile; apologies. If you have created a Rails app, the gem will be in the app's Gemfile.lock; not the generic Rails ones that you've posted.

Essentially, the Rails version you are installing is using a later version of Nokogiri than your Ruby version can cope with. What version of Rail are you installing and what method are you using to do that?

No I haven't made my first app yet, I'm just following this video https://teamtreehouse.com/community/video:70622 - to install rails on windows. But when I do the install command I get the "nokogiri requires Ruby version < 2.7.dev, >= 2.3." error

Understood - are you defining the Rails version to be 5.0.0?

Yeah, I used all the links in the teachers notes to install the correct files

Best thing to do here is to install the later version of Ruby, i.e. 2.3 or higher, but not higher than 2.6. You might need to remove the installation of 2.2.5 as switching between Ruby versions on Windows (I found) is a nightmare. The alternative is to try an older version of Nokogiri - I'm not sure if you can run gem install nokogiri 1.8.2, for example.

I finally got it to work!! If anyone else has this issue, the installer that worked for me was - https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.7-1/rubyinstaller-2.5.7-1-x86.exe

Thanks for your help steve!