Sunday, September 29, 2013

Installing Ruby + Rails on Windows 8 x64

1. Download and install Rubyinstaller (Ruby 2.0.0-p247 (x64) for me, you can try another version) from http://rubyinstaller.org/downloads/
2. Download and install Ruby Dev Kit (DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe for me) from http://rubyinstaller.org/downloads/

You can type in cmd or in cmd for ruby command "ruby --version" to check your ruby version.
Also you can check already installed gems by typing: "gem list --local" or "gem list --local rails" to check if rails already installed (for me it wasn't).

NB! You may need to configure your RubyDevKit to run "gem install rails". First of all you need to cd in command prompt to your rubydevkit root; then you need to run those cmds:
ruby dk.rb init
ruby dk.rb install

3. In cmd (or cmd for ruby) type "gem install rails"

After rails was installed, we need to install Sqlite 3 (the most difficult part of installation ^^), because rails use it as a default db engine. The problem is that we need to compile sqlite from source codes manually.
Now we will be using instructions, that was written by "paulwis" in this topic  https://github.com/luislavena/sqlite3-ruby/issues/82.
Also thanks to this topic: http://stackoverflow.com/questions/15480381/how-do-i-install-sqlite3-for-ruby-on-windows

4. Download source files of SQLite (sqlite-autoconf-3080002.tar.gz) and extract it somwhere ("C:/Sqlite/src/" for example.)
5. Open msys.bat file from RubyDevKit folder and change location using "cd" command to your sqlite source dir (for me it was "cd /C:/Sqlite/src/")
6. Run command "./configure"
7. Run command "make"
8. Run command "make install"
9. Now you need to install sqlite gem. Run command
"gem install sqlite3 --platform=ruby -- --with-sqlite3-include=[path\to\sqlite3.h] --with-sqlite3-lib=[path\to\sqlite3.o]"
for me it was:
"gem install sqlite3 --platform=ruby -- --with-sqlite3-include=/C:/Sqlite/src --with-sqlite3-lib=/C:/Sqlite/src/.libs/"
10. By the end you can check Gemfile.lock (in your rails application), if your version is correct. Make sure, that sqlite points to right version of ruby. Sometimes it needs to be changed for example from "sqlite3 (1.3.7-x86-mingw32)" to "sqlite3 (1.3.7-x64-mingw32)" or "sqlite3 (1.3.7)".

Now we can check our rails application. If it was not created yet, open command prompt or cmd for ruby, run "cd" to your applications folder (it can be any folder you prefer, f.e. "C:/MyRailsApps/" so you will run in cmd "cd C:/MyRailsApps/"). After run "rails new Hello_world" to create your Hello_world app. Than "cd Hello_world" and run "rails server". If all was ok, you can look at your app here: http://localhost:3000

No comments:

Post a Comment