I am here today to ask a question and then answer it. The question is: Can you run Ruby on Rails on a netbook? Specifically, an Acer Aspire One. My motivation is … since buying my netbook, i have completely fallen in love with it, and much prefer it to the desktop computer. I want to do as much as possible on the netbook. I don’t think i’d spend a whole day coding on it, but just for quick little things it could be wonderful!
Now that MyChores is open source i really like this idea of code anywhere. Wherever i have my netbook and an internet connection, i can code! If there’s an emergency bug needs fixing on MyChores, i could make the fix and push it. Or if i’m feeling lazy one Saturday morning there can surely be nothing better than a cup of coffee and coding in bed! ;)
So without further ado, let’s see if you can put Rails on a netbook …
Note from future-me … okay, i have been through this whole process and solved all the dependencies. To save you repeating all my mistakes i will try to lead you through the shortest path.
To get started, there’s a bunch of stuff we can just get from yum. Happy day.
sudo yum install gcc make openssl openssl-dev zlib zlib-devel sudo yum install openssh openssh-clients readline-devel
I don’t trust any package managers when it comes to Ruby. I have had too many bad experiences in the past. I always go to rubyonrails.org/down to see which version they are recommending, and i compile it myself. Today it is Ruby 1.8.7, p72.
cd ~/Downloads tar xfz ruby-1.8.7-p72.tar.gz cd ruby-1.8.7-p72 ./configure make make test sudo make install
I always like to do a quick test …
That little irb thing i did just there … i actually did that for real at work today! I was wondering how Hash made use of the
Enumerable#any? mixin. Just in case you were wondering!
Again, it’s a good idea to check on the Rails site to see if they mention any particular version. Today they don’t so i’m just going to get the latest, which is 1.3.1.
cd ~/Downloads tar xfz rubygems-1.3.1.tgz cd rubygems-1.3.1 sudo ruby setup.rb config sudo ruby setup.rb setup sudo ruby setup.rb install
Cheers, Jim, Chad and Eric from the RubyGems team! :)
gem --version 1.3.1
If you want Sqlite, download the source code from sqlite.org/download.html. You want the one that says “complete source tree”.
cd ~/Downloads tar xfz sqlite-126.96.36.199.tar.gz cd sqlite-188.8.131.52 ./configure make make test sudo make install
You should now be able to
sudo gem install sqlite3-ruby
For MySQL, you want this:
sudo yum install mysql-server mysql-devel sudo gem install mysql -- --with-mysql-config=/usr/bin/mysql_config sudo /etc/init.d/mysqld start
sudo gem install --no-rdoc --no-ri rails
Note from future-me … yeah i installed all the docs first time around. But then i thought, no way do i want them cluttering up my little netbook. If you installed them and later don’t want them, you can do this …
cd /usr/local/lib/ruby/gems/1.8 sudo rm -rf doc
Now we should be in business.
rails --version 2.2.2
We are winning.
Actually doing something in Rails!
Just a bit of scaffolding. We all like scaffolding, don’t we?! ;) Come on, little netbook, you can do this!
Yes, it can totally do it!
Running the web server
You probably have your own opinion of which web server is best. I personally feel happy with Mongrel, although i want to try some of the others. By default it’s still WEBrick.
sudo gem install --no-rdoc --no-ri mongrel
Let’s have a look, shall we!
Ahhh, scaffolding! :)
I don’t want to be running any Netbeans on this little machine, but i have used Gedit before and i get on well with it. It’s not as awesome as TextMate, but then again, what is?
sudo yum install gedit
It has some pretty sweet plugins. Until somebody writes TextMate for Linux, it will do.
If you want to install Git (and if you know what it is, you very probably do!) you may have a problem with perl not being able to find its MakeMaker. I downloaded version 5.8.8 from perl.org/get.html and installed it myself. It took almost forever, but its Configure script was very funny!
cd ~/Downloads tar xfz perl-5.8.8.tar.gz cd perl-5.8.8 sh Configure -Dcc=gcc make make test sudo make install
I then downloaded Git 184.108.40.206 source code from git.or.cz.
cd ~/Downloads tar xfz git-220.127.116.11.tar.gz cd git-18.104.22.168 ./configure make make test sudo make install
The tests appear to run several thousand Git commands, which gives me a huge confidence that my netbook is well up to the challenge! :)
git --version git version 22.214.171.124
You’ll probably also want Gitk which is available from yum.
sudo yum install gitk
It’s a shame i can’t get in to change the font size down. Gitk is blatantly made for huge screens – i can’t even see the whole options dialog box to fix the font.
In answer to my question, i reckon YES! It is possible and joyful to code on a netbook! It runs Rails just fine, and i think i’m going to enjoy it.
I’ll let you know when i’ve cloned a few GitHub repositories and worked on a real project … but the initial signs are looking very good indeed. Just what i wanted to find out! :)