Ruby is fun to work with. But sometimes, it just does not play well with Windows, it works better in Linux! Many plugins or gems (like xmlparser, xmlscan and uconv for rss library, and EventMachine, rack for thin) require compiling C code, that is usually difficult to install for Windows user, until some kind people make a Windows binary. Some libraries (like newer versions of BackgrounDRb) do not work on Windows at all. Ruby interpreter on Linux is also faster. One of my Rails app runs 2 times faster in Linux! So, why not install Linux inside Windows?
andLinux is a complete Linux system running seemlessly in Windows. It uses CoLinux as its core and runs Linux Kernel natively. It achieves performance near that of a standalone Linux. And the resource requirements are also low, especially when compared with traditional virtualization solutions, such as VMWare and Virtual PC. I have been using andLinux for few months and I am happy with it. My benchmark with thin was also done in andLinux!
OK, enough for introduction. Here are the steps I took to prepare Ruby and Rails development environment with andLinux. It tooks me 15 min manual work + 2 hours of downloading, compiling and installing.
Install andLinux
- Go to andLinux download page download and run Beta 1 (minimal version) installer
- Choose "run andllinux manually as a NT service + use windows shortcuts" such that andLinux run transparently in background
- Choose "Using cofs (easy configuration)" then input D:\my\path, this path would be available in andLinux at ~/windows
- Installer would setup Windows service and network interface in Windows
- Restart Windows
- After restart, you can use net start andlinux to start andLinux at background (when need to shutdown andLinux, run net stop andlinux)
- Double click on the shortcut "andLinux Console (NT)"
- Login with root with empty password. You are now connected to andLinux terminal, right inside your Windows!
- Run passwd to setup password
Setup SSH
- Assume you have Cygwin with SSH installed, run ssh-user-config in bash to generate SSH keys if this was never done
- By default, andLinux has IP address of 192.168.11.150
- Run scp -r ~/.ssh root@192.168.11.150:~/.ssh copy SSH keys to andLinux
- Now, you can run ssh root@192.168.11.150 to login andLinux
- The andLinux Menu icon at the lower right corner is no longer neccessary for me, it can be disabled by running msconfig, in Startup tab, uncheck XFCE Menu (andLinux) and Xming (andLinux), and click OK
Install non-Ruby packages
andLinux comes with handful package management system - APT. Run the following commands in andLinux to install non-Ruby packages. You can install more packages in one line to save manual time. You may exclude Subversion, MySQL or SQLite if you are not using them
- apt-get update
- apt-get upgrade
- apt-get dist-upgrade
- apt-get install build-essential openssl libssl-dev libopenssl-ruby libreadline5 libreadline5-dev libzlib-ruby libyaml-ruby subversion git-core mysql-server libmysqlclient15-dev libmysql-ruby sqlite3 libsqlite3-dev ruby1.8 irb ri rdoc ruby1.8-dev
Install Ruby packages
Unfortunately, APT does not give you up-to-date Ruby interpreter, which cause problems with many Ruby packages. We need to install Ruby interpreter on our own.
- Go to Ruby download page and download latest stable 1.8 tar ball (e.g. wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz)
- Extract (e.g. tar zxvf ruby-1.8.6-p111.tar.gz), compile and install Ruby interpreter (./configure; make; make install)
- Go to RubyGems download page and download latest tar ball
- Extract and run ruby setup.rb
- Install gems for Rails development: gem install --no-ri --no-rdoc rails mysql sqlite3-ruby mongrel ruby-debug
- You can certainly install your favourite gems as you like
That's it! The best of it is we can archive whole directory and take to anywhere. Happy Ruby development!


4 comments:
apt-get install ruby irb rdoc gem
seems to be working for me
there's also apt-get install ruby1.9
Pardon my noob question, but how would you view your Rails app through andLinux when andLinux runs on a port and your Rails app runs on a port?
"Reply to: How would you view your Rails app through andLinux when andLinux runs on a port and your Rails app runs on a port?"
Andlinux automatically installs a virtual network "card" thing called TAP-Colinux on windows which communicates with the other virtual network card on the Andlinux guest OS (ubuntu). Because of the separate virtual network devices there is no conflict of ports.
I hope this answers the question
Excellent tutorial. Just what I was looking for. I tried Ruby on Rails on many setups:
1.) Dual-boot with Ubuntu (problems: driver issues, missing windows apps)
2.) Ruby on rails in windows vista (problems: slow)
3.) Ruby on rails in cygwin in Vista(problems: even more slow)
4.) Ruby on rails in virtual box (Problems: slow, high memory footprint)
5.) Ruby on rails in andLinux ==> ROCKS!!
Thank you so much for this useful tutorial. But strangely this is the only blog which contains information about andLinux and ROR. Nobody seems to mention it or know about it.
You are awesome!
Post a Comment