Installing RubyGems in Windows
I’m new to ruby. I tried to install Ruby Gems on my PC by following the steps given in the site http://rubygems.org/pages/download.
I downloaded the package from the mentioned site, changed the directory to the directory in which the setup resides, and tried to run setup using the command setup.rb in command prompt.
But I get a window pop up that says «Windows can’t open this file» and prompts me to select a program to open this file.
What should I do now? Let me know if I am doing something wrong.
7 Answers 7
I recommend you just use rubyinstaller
It is recommended by the official Ruby page — see https://www.ruby-lang.org/en/downloads/
We have several tools on each major platform to install Ruby:
- On Linux/UNIX, you can use the package management system of your distribution or third-party tools (rbenv and RVM).
- On OS X machines, you can use third-party tools (rbenv and RVM).
- On Windows machines, you can use RubyInstaller.
To setup you Ruby development environment on Windows:
Check your ruby version: Start — Run — type in cmd to open a windows console
For Ruby 2.4 or later, run the extra installation at the end to install the DevelopmentKit. If you forgot to do that, run ridk install in your windows console to install it.
Ruby MYSQL2 gem installation on windows 7
I’m trying to installing the mysql2 gem on windows 7 I downloaded the connector from the mysql site and placed the libmysql.dll in ruby200\bin
then do gem install mysql2
These are the results am I being dim here?
17 Answers 17
EDIT 30/09/2014
When this answer was posted the 64 bit rails installer wasn’t the recommended version — it now seems people are starting to use it more. It should be noted when you download the MySQL Connector you need to download either 64 or 32bit to correspond to the version of rails you installed.
Amazingly I lucked upon an answer very early this morning as I happened to be looking for something else of a similar nature. I’m not quite sure why there isn’t a single simple guide for this as it appears to be very straight forward!
For some reason just specifying the mysql-dir when you install the gem doesn’t pick up with other sub directories so you need to set the parameters manually.
For anyone else experiencing the same problem, I did the following:
NOTE Don’t download the installer, download the ARCHIVE for your OS
Download either the 32bit or 64 bit ARCHIVE to correspond with the version of rails you installed.
2) Extract the file to C:\mysql-connector
Voila everything is working fine.
EDIT 30/01/2014
I just had to do a fresh install on a bricked machine and the command in step 3 didn’t work, what did work was:
I’m not quite sure what the difference is but this time it seems to be picking up the directories ok, so if the first one doesn’t work try this one!
I think this has to do with how you go about installing rails, this time round I used the railsinstaller which seems to set the paths up correctly.
A lot of the outcome here seems to depend on the shell your using, a lot of people are having problems with powershell so I wouldn’t advise using it. I did this in an elevated command prompt.
mysql ruby gem not installing on Windows 7
Not a duplicate. This question is mysql gem and the other question is mysql2 gem. They do have the same answer though, but the other question’s answer doesn’t tell what the solution is explicitly. The answer is hidden in the comments. See yellow text of the answer for this question contains the solution.
Below is an error I’m receiving when trying to install the mysql gem on Windows.
How did I get to this point?
- Installed Python for Windows. This step probably has nothing to do with my error, but I’m including it since it is required for the build I’m deploying.
- Installed Ruby for Windows. Looks like I downloaded the «rubyinstaller-2.2.2-x64.exe and installed that.
- Installed Ruby Gems. Looks like I downloaded and extracted «rubygems-2.4.7.zip».
Then ran these commands from the Windows command prompt:
. was installed in C:/Ruby22-x64/bin/gem
Then I tried installing the mysql gem like so. And got an error.
C:>gem install mysql Fetching: mysql-2.9.1.gem (100%) ERROR: Error installing mysql: The ‘mysql’ native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit from ‘http://rubyinstaller.org/downloads’ and follow the instructions at ‘http://github.com/oneclick/rubyinstaller/wiki/Development-Kit’
So I followed the instructions. I went to that page (http://rubyinstaller.org/downloads). Looks like I downloaded «DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe». When I extracted the stupid extractor put the files in the same directory with everything else. So make sure you make a new folder after downloading, and before extracting.
Then I ran this command.
Then I ran this command, and got an error.
I had to make sure the «config.yml» file pointed to the C:\Ruby22-x64 folder on my machine for where Ruby was installed. I removed the comment and change the path. Then reran the command, and it worked.
Then ran this command.
Then tried to re-install the mysql gem. And got the error in my question. What a gem! «I got you jewels Betty, jewels!»
gem install mysql
EDIT 5/21/2015:
Per the question below, I’m getting a new error.
1 Answer 1
The ‘mysql’ and ‘mysql2’ packages/extensions/gems don’t work with the x64 bit version of Ruby on Windows 7 (or any 64 bit version of Windows). You need to install the x86 (32) bit version of Ruby for them to work.
So I repeated step 3 in my question, and installed version 1.9 instead taking the advice from my comment in my question (on issue 191) by luislavena on August 30, 2013. This is the x86 (32 bit) version. Got it from here.
Looks like the file’s name is «rubyinstaller-1.9.3-p551.exe».
Then completed step 4. The Ruby developers must have fixed their scripts to modify the config.yml file automatically for the x86 version. I didn’t have to edit this time.
Then for step 5, I installed this devkit exe, because the newer version of Ruby didn’t have a dev kit that was x86.
For step 6, I placed into it’s own folder. It still extracts files in the exe root, not a folder of the exe root. Then ran all the commands except for the last one. It still threw the error.
Then for step 7, I ran this.
It installed the x86 version of mysql gem, because I can see the gem, by running this. It’s very shiny and looks expensive!
5/26/2015 update:
Latest version of Ruby when installed on Windows that allows you to start the Rails server is 2.1.6.
Starting the rails server didn’t work by running «rails s». I had to go back and uninstall old versions of Ruby. See my answer here. Ignore the other answers if you are on Windows.
The only stable version of Ruby on Windows that allows you to start the rails server is «rubyinstaller-2.1.6.exe». «rubyinstaller-2.2.2.exe» throws the following error:
I can’t install rmagick gem on windows
I used ruby 1.9.2 and rails 3.0.3. iam trying to install rmagick gem but when i run bundle install I got an error tells me:
I installed ruby from http://rubyinstaller.org/downloads/ with development kit and the latest version of ImageMagick. I tried to set rmagick configurations (lib and include directories) but I still get the same error
any help? any thoughts to solve the issue?
5 Answers 5
Prerequisites:
Ruby > 1.8.6
DevKit (any version)
No other ImageMagick installation or PATH entry
Step 1: Installing ImageMagick:
Install ImageMagick:
*Important: The installation path should NOT contain any spaces.
Ideally select “C:\ImageMagick″
Please make sure to select the below options:
Add application directory to your path system
Install development headers and libraries for C and C++
Step 2: Installing rmagick:
Use the following command to install rmagick gem:
I have the same problem, my environment was:
I install rmagik gem successfully, after reinstalling of ImageMagick from v6.8.8 to 6.6.7. It was just a problem of incompatibility versions.
Use rmagick-win32 gem, and it doesn’t need ImageMagick separately. This is bundled.
Please refer to this thread in RubyInstaller group that points to our Tutorials page where you can find this blog post describing the installation method.
First of all clear your path environment variables. (This is the main step that people often skip, but very important). This is the main reason for the error you’re facing.
Then install the rails installer (2.0.0) from here : http://railsinstaller.org/en
It’ll set up ruby, rails, and everything else you need. This will also set up your environment path variables for you as well.
Next install imagemagick 6.7.9.9 or lower and while installing check the option to include C headers. Make sure you install it within the rails installer folder.
Then type this in your command prompt path=c:\RailsInstaller\ImageMagick-6.7.9-Q8;%path% or whatever version you have.
Finally edit C:\RailsInstaller\Ruby2.0.0\setup_environment.bat to include the path to ImageMagic
At line 25: SET PATH=c:\RailsInstaller\ImageMagick-6.7.9-Q8; or whatever version you have
Installing bcrypt-ruby gem on Windows
I’m trying to install bcrypt-ruby on Windows Vista.
So far, I have been able to install nmake.exe from a MS knowledge base article and cl.exe from installing Visual Studio 2008 Express.
However, I am now encountering this error:
I’ve already executed VCVARS32.bat which presumably sets up the environment. I am suspecting that the warnings and errors are due to installing newer version of Visual Studio.
Has anyone done this successfully? I do not have a copy of Visual Studio 6.0.
7 Answers 7
The better, easiest way is to install the development kit:
- Download devkit- .7z from here;
- unpack it in the Ruby directory (for instance, C:\Ruby , so that you’ll have C:\Ruby\devkit ;
- from command line, type: gem install bcrypt-ruby .
For me, the following worked
To be able to build a gem extension for One-Click Installer (OCI) you need VC6. Mxing and matching different versions of newer Visual Studio will fail or will generate unknown errors during runtime.
I would recommend avoid all these hassles and proceed with the successor of One-Click, which is called RubyInstaller.
- Download and install either 1.8.6 or 1.9.1 RC1 packages, announced at RubyForge
- Download the Development Kit, and unpack it on your Ruby installation
- Follow INSTALL.txt instructions to adjust the DevKit to the location you extracted it
- Proceed with gem install bcrypt-ruby , will work out of the box
For more details about using other gems or Rails with this newer version, please see the tutorials section in our Wiki.