Hi all,
RailsFTW guy here. Yesterday I promised Nic that I'd share some details about our installer in order to give some ideas for the new InstantRails.
I hacked together RailsFTW as a proof of concept package/installer for future Rails-promoting events in our country (eg.
RailsJam). As a Rails instructor, I knew the basic problems behind introducing Rails to Filipino students:
- Most students (even in college computer labs) use Windows as their OS in their machines. The most up to date installation guides for installing Ruby and Rails are for Linux and Mac leaving the teachers (who are using the latter OSs for day to day use) scratching their heads on how to install RoR on the machines.
- Internet access is a problem. To put it bluntly, internet access sucks in our country. Thus, running "gem install rails" would waste hours of precious teaching time. Also, some schools restrict internet access preventing RubyGems from downloading the gems from the internet.
The idea behind RailsFTW is to create an installer that we can put in CDs or disposable USB drives (along with IDEs, free ebooks, XAMPP, Notepad++, etc) that we would just distribute at the beginning of the workshops. Once RailsFTW is installed, the students would simply go along with the workshop; they don't need to worry about gems or the OS unless they need to install some special gems (which probably wouldn't be covered by the workshop).
tl;dr: Installing RailsFTW should allow one to follow
http://guides.rubyonrails.org/getting_started.html without downloading anything else.
Without further ado, here are the steps I used to build RailsFTW:
Initial setup and compileDownload and install RubyInstaller, Inno Setup QuickStart Pack, and Git for Windows.
Checkout RubyInstaller source. Git should checkout newlines as-is.
Run "rake ruby19" in the RubyInstaller source folder to download and compile Ruby.
Installing the gemsWe need to install the gems under the recently built ruby binaries so that they'll be included in the package. Go to the bin directory of the newly compiled Ruby and install Rails and SQLite via:
{rubyinstaller}\sandbox\ruby19_mingw\bin> gem install rails sqlite3-ruby --no-ri --no-rdoc --env-shebang
As mentioned by the gem installation, download the Windows DLL from
http://www.sqlite.org/download.html and extract it to {rubyinstaller}\sandbox\ruby19_mingw\bin.
Now to install the mysql2 gem. First download and extract the mysql-noinstall-5.1.51-win32.zip from
http://dev.mysql.com/downloads/mysql/. Assuming you extracted it to C:\mysql-noinstall-5.1.51-win32, the following command will install the gem:
gem install mysql2 --platform=ruby -- --with-mysql-include=C:\mysql-5.1.51-win32\include --with-mysql-lib=C:\mysql-5.1.51-win32\lib\opt
Once the gem is installed, we need to copy the C:\mysql-5.1.51-win32\bin\libmysql.dll to {rubyinstaller}\sandbox\ruby19_mingw\bin. In RailsFTW, I used the libmysql.dll of
MariaDB. (I can't build the gem from MariaDB's current no-install binaries, but good news is that the DLL works: we have a plan B in case Oracle goes crazy with lawsuits for MySQL.)
Changes before packagingDelete/move gems from {rubyinstaller}\sandbox\ruby19_mingw\lib\ruby\gems\1.9.1\cache to reduce the size of the installer.
I tried compiling the CHM help file for Ruby 1.9 but after a while I gave up and just modified {rubyinstaller}\recipes\packager\inno.rake and {rubyinstaller}\resources\installer\config-1.9.2.iss to remove it.
At this point, the changes I made to the installer are purely cosmetic. I've modified the {rubyinstaller}\resources\installer\rubyinstaller.iss to make the installer look like a different package altogether (e.g. RailsFTW instead of RubyInstaller). I've also modified {rubyinstaller}\resources\installer\ri_gui.iss to have the "Add Ruby executables to your PATH" ticked by default (I explained this before in my
blog post). And finally, I also modified the Railties gem to remove the color in the logs (config.colorize_logging = false) which people won't probably see in Windows anyway.
Packaging the whole thingRun "rake ruby19:package", then rename the rubyinstaller-1.9.2-p0.exe to something like rails-ftw-v0.2.exe.
And that's it. It's very simple, but I haven't tried automating the whole thing via Rake yet.
--
Bryan Bibat
Freelance Software Engineer
http://www.bryanbibat.net