How to install ruby on rails with sqlite3 on windows 7?
I have started working on ruby on rails and need to install it on windows 7. I searched on google and found installation help on different sites that is not complete for all packages, so I am writing here and hope it will be helpful.
I downloaded packages related to ruby on rails that are pik-0.3.0.pre, rubyinstaller-2.0.0-p247-x64, DevKit-mingw64-64-4.7.2-20130224-1432-sfx, sqlite-autoconf-3071700.tar.gz.
pik-0.3.0.pre is a tool to manage multiple versions of ruby on windows and it can be used from git bash, windows command line.
Install pik
First install pik anywhere in your system. I installed on D drive, so when successfully installed, open your command line(cmd.exe). Run following command
>pik help commands
Note: if pik is undefined command then check your environment variable. You have to create environment variable for this.
You will see following list
Now before proceed to next first download other packages. Download rubyinstaller-2.0.0-p247-x64 and DevKit-mingw64-64-4.7.2-20130224-1432-sfx from
http://rubyinstaller.org/downloads/
Install Devkit
After downloading extract both on your drive. To install Devkit, open command prompt (cmd.exe) and cd to the folder where you installed devkit and run following commands
>ruby dk.rb init
and
>ruby dk.rb install
Note: if “ruby” is not working then create Environment Variable for ruby.
Add Ruby to pik
Now add ruby to pik by running following command.
>pik add ruby (or path to ruby directory).
Install Rails
Now install rails for this run following command.
>pik gem install rails
It will install different gems that will be used by rails. It will take some time to complete installation.
After that you can see gems list by following command.
>gem list
Or
>pik gem list (this command will show ruby version too)
Install Sqlite3
Till now pik, ruby2.0.0, and devkit is installed. Sqlite is the default db server for rails, so now you need to install sqlite3. To do this, follow following steps.
Download and extract the autoconf package from http://sqlite.org/download.html
- Run msys.bat (you can find it in the ruby devkit root folder)
- cd into the path where you downloaded the sqlite source (for instance: “cd /d/sqlite3” for path “d:\sqlite3” if you are new to MSYS/MINGW32)
- Run “./configure”
- Run “make”
- Run “make install”
Now we need to install sqlite3 gem again, this time specifying the platform and the path to the newly compiled binaries:
gem install sqlite3 --platform=ruby -- --with-sqlite3-include=[path\to\sqlite3.h] --with-sqlite3-lib=[path\to\sqlite3.o]
For example, I used it as with my sqlite3 path:
gem install sqlite3 --platform=ruby -- --with-sqlite3-include=/d:/sqlite3/ --with-sqlite3-lib=/d:/sqlite3/.libs/
It will take some time to install sqlite3 gem, you will see installation process command on MSYS.
Whenever you create rails app make sure it points to correct sqlite3 version. You can edit your Gemfile of your app and comment # gem ‘sqlite3’ and add gem ‘sqlite3′,’1.3.7’ save it and go to command prompt (cmd.exe) or git bash, cd to your application and run command “rails server” now check your application in browser.
Congrats you have installed ruby on rails with sqlite3 on windows.