Bundler installing gems into the wrong directory – mea culpa
So I spent an hour and a half last night unfairly swearing at the spork gem; and blaming it for everything from world hunger to banking crises! This is because somehow when installing spork I had managed to change the location that bundler installs gems into - strangely enough into a directory called ./spork under my project directory. And I figured the blame landed at the door of the spork gem. Here's what happened just so that you don't get caught out.
Once installed, here's how you start up spork: bundle exec spork
But, at some point, here's what I did by accident: bundle install spork
Fool! Fool! Fool! For those of you that aren't familiar with the 'path' argument to bundler, well, what it does is permanently change your path to the value you specify. So for an hour and a half last night, I had ./spork set as my gem directory. Meaning that my furious efforts to correct the problem were in vain - such as clearing out all the gems and reinstalling, grepping for a config file that could be pointing at ./spork in my project and rvm directories.
What I should have done to fix this problem immediately, was to tell bundler to use my standard rvm directory for gems again
bundle install --system
Ta da!
It's pretty confusing that specifying a path argument once off should cause bundler to change it behaviour on a permanent basis but at least I notice that in the docs it says
The path argument to 'bundle install' is deprecated. It will be removed in version 1.1. Please use 'bundle install --path spork' instead.
So I guess I'm not the only one who's hit this confusing behaviour. Long live the --path option!
Sorry spork, I'm a dork...
Installing Ruby on Rails on MeeGo with SQLite
This post will go through installing Ruby on Rails 2.3.2 on MeeGo - though it should likely work for any version of Rails, including Rails 3 (though the actual Rails commands at the end of this guide will be a little different). Firstly go through the Installing Ruby and Rubygems on MeeGo guide to get at least Ruby 1.8.7 on your system and then carry out the following steps.
PRE-REQUISITES
* The above guide requires you to disable the core repository and then enable the devel and testing repositories. I found that when following the below steps, I would get an error trying to install sqlite3 gem itself - saying that the sqlite3.h header could not be found. I had to run the following commands first
# Update all packages on the system
sudo zypper update
# Then the chrome browser would not work saying
[declan@declan-desktop grr]$ chromium-browser/usr/lib/chromium-browser/chromium-browser: error while loading shared libraries: libicuuc.so.42: cannot open shared object file: No such file or directory
# To fix this, I had to update chromium-browser separately
sudo zypper update chromium
Ok, so onto the actual install steps for Rails and SQLite3...
RAILS INSTALLATION
#Install ruby and sqlite development headers (as we'll be using sqlite as our backend)
sudo zypper install ruby-devel
sudo zypper install sqlite-devel
# Install tools for building C-based gems
sudo zypper install make # Not 100% sure that make is needed
sudo zypper install gcc
# Install sqlite3 gem for ruby
sudo zypper install sqlite3-ruby
# Install Rails
sudo gem install rails -v 2.3.2
# Create a new Rails application
rails grr
# Create a thing (ok, more correctly called a resource) in Rails
cd grr
./script/generate Animal name:string
# Create the database
rake db:migrate
# Fire up the Rails web server
./script/server
# And then browse to your site in the web browser - http://localhost:3000/animals
Hurrah! Everything works! (At least I hope it did!). Happy Rails development!
Installing Ruby and Rubygems on Meego
Thanks to some great people on the Meego mailing lists I can happily show you how to get recent versions of Ruby and Rubygems running on your beloved MeeGo. The steps I present here are simply extracted from the guide at http://wiki.meego.com/Quality/QA-tools/TDriver
Once the more recent Ruby releases (1.8.7 and higher) gain more traction in MeeGo they will likely move into the core repository. So, be sure to see if they are there before changing adding/removing repositories as it outlined here.
Warning: You need to disable the MeeGo core repository and enable the testing and development repositories so be sure that you're happy to do this before continuing.
Steps:
#Remove the MeeGo core repo
sudo zypper rr core
# Enable the testing repo
sudo zypper ar http://download.meego.com/live/Trunk:/Testing/standard/Trunk:Testing.repo
# Enable the dev repo
sudo zypper ar http://download.meego.com/live/devel:/quality/testing/devel:quality.repo
If you run into trouble remove this last repo with the command. If you do so you will be able to go no further.
sudo zypper rr devel_quality
# Install Ruby 1.8.7
sudo zypper install ruby
# Install rubygems
sudo zypper install rubygems
Yay! You're done! This guide would likely not have happened unless the MeeGo conference and its sponsors had not given away free MeeGo netbooks to the smiling attendees. Well done guys! And thank you!
Deploying your Qt on Rails apps on the N900 (Maemo)
Qt on Rails is a framework to let you turn your Rails sites in desktop applications and harness the power of Ruby! It's not at production level yet but it's certainly possible to have a good play with it and a bit of a hack! If you're not familiar with Qt on Rails then a good place to start is this blog post covering the v0.1 release. Also, check out the github repo for more info on installing Qt on Rails on your desktop and building an application with it. Here we show you how to deploy Qt on Rails based apps on your N900. One of the goals of Qt on Rails is to provide an easy way for you to develop apps faster for Maemo and, down the road, hopefully MeeGo too!
Note: This blog post may help you figure out how to install any QtRuby application on the N900, not just Qt on Rails apps. Also, this QtRuby Maemo wiki article was particularly useful when I was stumbling along this path!
One thing you will need to install as part of this guide is Easy Debian. Easy Debian greatly expands what you can do with your Maemo device. It basically sticks a full-featured version of Debian on your device. This means 2 things - firstly, for the uber-geeks out there it let's you fire up a Linux desktop on the N900; though it's important to note that your normal Maemo desktop isn't affected by Easy Debian. Secondly, having a full-on Debian available let's you run Linux apps such as Open Office! Sweet! And what rocks is that you can even run these programs without invoking the Easy Debian Linux desktop - in a seamless manner. It's important to note that the user interface to these Easy Debian-based apps behave a differently to a typical native Maemo program; rather they work like a traditional desktop application with a mouse pointer on screen.
- Note: For simplicity, this guide assumes you are installing an application which stores data using sqlite3. Also, the steps here have been tested against the N900 firmware update PR1.2. If you are using an older version of the firmware you may want to consider updating it.
- Firstly, install Easy Debian with the N900's Application Manager
- Install the Easy Debian image via the new Deb Img Install application added to your list of applications
- Note: This is a 1 gig download, but comes with cool stuff like OpenOffice and intergrates pretty seamlessly with your desktop
- Takes an hour or so to download and then extract itself
- Open the Debian Chroot terminal (not the usual N900 terminal), which should now be in your list of applications
- Install rubygems, qtruby and sqlite3 with ruby bindings
- sudo apt-get install rubygems
- sudo apt-get install libqt4-ruby
- apt-get install libsqlite3-ruby
- Install the bits we need need from Rails (without installing documentation)
- sudo gem install activerecord activesupport activeresource --no-ri --no-rdoc
- Zip up your Qt on Rails application and copy to any directory on to the N900. Note that the Qt on Rails application consists of the entire Rails directory directory including the vendor/plugins/qtonrails directory intact and a sqlite3 database already created under the db directory).
If you don't have your own Qt on Rails application to hand then you can create the RadRadio app discussed in the "Make it so, Jim!" section of the v0.1 release blog post
In the Qt on Rails v0.1 release there is a bug that accidentally introduces a dependency on a korundum library, which is not needed in this case. An issue is logged against this in the Qt on Rails Issue Tracker As a workaround, find and remove any occurrences of
require 'korundum4'in files under thevendor/plugins/qtonrails/appdirectory - Once transferred, simply unzip it on your device. Note: If you saved the zip to the Documents folder on your N900, this can be found under /home/user/MyDocs/.documents when poking around the filesystem
- Finally, via the good ol' Debian Chroot terminal, change directory to the vendor/plugins/qtonrails directory of your app and execute
ruby1.8 run - Boom! You should see your Qt on Rails app in all it's glory!
Note there is a bug where you cannot input into a text field when running a Qt on Rails app on the N900 using above technique (seamless mode). As a workaround, open the Qt on Rails app inside of the Debian LXDE desktop (rather than in seamless mode). You can find Debian LXDE in the list of applications on your device. Inside Debian LXDE, open a terminal and run the application as above. Just a quick heads up, sticky keys don't work like you'd expect - you have to hold down the Shift and Fn keys to use them.
Installing Ruby On Rails on Windows
There were a couple of great outcomes from the first Free Ruby Lesson we ran in the Havana cafe on Dublin's Georges St last Monday. The first was getting everyone hacking with the Rails stack and some practical examples in double quick time. The second was managing to get RoR installed on Windows Vista as the lesson rumbled on in the background. Here's how Rails conquered Vista.
We kicked off by following the instructions on the rails wiki. It's worth paying careful attention to anywhere it says to set path variables. If you find that you are getting an error that says that you version of rubygems is not recent enough (and you can't get rubygems to update itself) then you can install an older version of Rails, for example 2.3.2, using the following from the command line
gem install rails -v 2.3.2
(Note: If you have already installed a different version of rails you can uninstall it first by using 'gem uninstall rails').
The big problem however was getting sqlite3 working. We did install the SQLite Command Line Tool and the SQLite DLL as the Rails Wiki instructions said to - but to no avail. We kept getting a popup error saying that the sqlite3 dll was not found and to please consider reinstalling. Fortunately, we gambled on one of the answers on StackOverflow. Basically the solution was from the command line
gem uninstall sqlite3-ruby
gem install sqlite3-ruby --source http://gems.rubyinstaller.org
And with that we were away! The final thing was to get a nice friendly IDE installed so we plumbed for Netbeans on the Netbeans Downloads page. Look out for the special Ruby version of Netbeans which is one of the links around the middle of the downloads page.
Anyway, that's all for this week. Happy Ruby hacking!