Thursday, December 30, 2010

Install Mail, a Ruby Gem

Installation of mail gem is simple.
It supports both 1.8.x and 1.9.1.

$ sudo gem install mail
Successfully installed mime-types-1.16
Successfully installed polyglot-0.3.1
Successfully installed treetop-1.4.9
Successfully installed i18n-0.5.0
Successfully installed mail-2.2.13
5 gems installed
Installing ri documentation for mime-types-1.16...
Installing ri documentation for polyglot-0.3.1...
Installing ri documentation for treetop-1.4.9...
Installing ri documentation for i18n-0.5.0...
Installing ri documentation for mail-2.2.13...
Installing RDoc documentation for mime-types-1.16...
Installing RDoc documentation for polyglot-0.3.1...
Installing RDoc documentation for treetop-1.4.9...
Installing RDoc documentation for i18n-0.5.0...
Installing RDoc documentation for mail-2.2.13...
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'mail'
=> true
irb(main):003:0> exit
$ sudo gem1.9.1 install mail
Successfully installed mime-types-1.16
Successfully installed polyglot-0.3.1
Successfully installed treetop-1.4.9
Successfully installed i18n-0.5.0
Successfully installed mail-2.2.13
5 gems installed
Installing ri documentation for mime-types-1.16...
Installing ri documentation for polyglot-0.3.1...
Installing ri documentation for treetop-1.4.9...
Installing ri documentation for i18n-0.5.0...
Installing ri documentation for mail-2.2.13...
Installing RDoc documentation for mime-types-1.16...
Installing RDoc documentation for polyglot-0.3.1...
Installing RDoc documentation for treetop-1.4.9...
Installing RDoc documentation for i18n-0.5.0...
Installing RDoc documentation for mail-2.2.13...
$ irb1.9.1 
irb(main):001:0> require 'mail'
=> true
irb(main):002:0> 


Reference: https://github.com/mikel/mail

Saturday, December 18, 2010

Installing Qt-Ruby

[Update] Currently I use qtbindings instead of Qt-Ruby. The main reason I switched is that Qt-Ruby is not in active development and has not support for Ruby 1.9.x. See "Installing qtbindings on Ubuntu" (http://socrateos.blogspot.com/2011/05/installing-qtbindings.html). So the instruction below is no longer relevant for me.


1. Install Qt
Open Ubuntu Software Center from Application menu.
Find Qt Creator in Development/IDE group and install it.

2. Install Qt-Ruby
Open Synaptic Package Manager
Search for qt-ruby
Install libqt4-ruby

3. Test Qt-Ruby installation
$ irb
irb(main):001:0>require 'Qt4'
=> true
irb(main):002:0> 

4. Write simple program.
# helloworld.rb
# based on tutorial on http://www.darshancomputing.com/qt4-qtruby-tutorial/ 
# 
require 'Qt4'

app = Qt::Application.new ARGV
btn = Qt::PushButton.new 'Hello, World!'
btn.resize 100,30
btn.show

app.exec

5. Run it






6. Resouces
http://www.darshancomputing.com/qt4-qtruby-tutorial/

7. Notes.
There is no Qt-Ruby for Ruby 1.9.1 in the repositories.
Is there any, somewhere?

Wednesday, December 8, 2010

Installing Sinatra

Install sinatra.
$ sudo gem install sinatra
Successfully installed rack-1.2.1
Successfully installed tilt-1.1
Successfully installed sinatra-1.1.0
3 gems installed
Installing ri documentation for rack-1.2.1...
Installing ri documentation for tilt-1.1...
Installing ri documentation for sinatra-1.1.0...
Installing RDoc documentation for rack-1.2.1...
Installing RDoc documentation for tilt-1.1...
Installing RDoc documentation for sinatra-1.1.0...
$ sudo gem1.9.1 install sinatra
Successfully installed rack-1.2.1
Successfully installed tilt-1.1
Successfully installed sinatra-1.1.0
3 gems installed
Installing ri documentation for rack-1.2.1...
Installing ri documentation for tilt-1.1...
Installing ri documentation for sinatra-1.1.0...
Updating class cache with 2246 classes...
Installing RDoc documentation for rack-1.2.1...
Installing RDoc documentation for tilt-1.1...
Installing RDoc documentation for sinatra-1.1.0...

Test the installation.
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'sinatra'
=> true
irb(main):003:0> exit
$ irb1.9.1 
irb(main):001:0> require 'sinatra'
=> true
irb(main):002:0> exit
$ 

Sunday, December 5, 2010

Installing wxRuby (2) - failure

I tried to install wxRuby on a new laptop, and it failed.
$ irb
irb(main):003:0> require 'rubygems'
=> true
irb(main):004:0> require 'wx'
LoadError: libwx_gtk2u_stc-2.8.so.0: cannot open shared object file: No such file or directory
However, it did work after installation of wxWidgets (see my "Installing wxWidgets"). Alex Fenton says "On Linux, the gem only installs the ruby interface to the wxWidgets library, not the core wxWidgets library code itself." (http://web.archiveorange.com/archive/v/HCYBSYWLHZM4afalzm69)
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'wx'
=> true
irb(main):003:0> 

Unfortunately, in the current version of wxRuby, it only works for Ruby 1.8.7, not for 1.9.1.
~$ irb1.9.1
irb(main):001:0> require 'wx'
/var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wxruby2.so: [BUG] unknown type 0x22 (0xc given)
ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux]

-- control frame ----------
c:0028 p:-39694812 s:0097 b:0097 l:000096 d:000096 TOP   
c:0027 p:---- s:0095 b:0095 l:000094 d:000094 CFUNC  :require
c:0026 p:0011 s:0091 b:0091 l:000090 d:000090 TOP    /var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wx.rb:12
c:0025 p:---- s:0088 b:0088 l:000087 d:000087 FINISH
c:0024 p:---- s:0086 b:0086 l:000085 d:000085 CFUNC  :require
c:0023 p:0011 s:0082 b:0082 l:00047c d:000081 EVAL   (irb):1
c:0022 p:---- s:0080 b:0080 l:000079 d:000079 FINISH
c:0021 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC  :eval
c:0020 p:0027 s:0071 b:0071 l:000070 d:000070 METHOD /usr/lib/ruby/1.9.1/irb/workspace.rb:80
c:0019 p:0031 s:0064 b:0063 l:000062 d:000062 METHOD /usr/lib/ruby/1.9.1/irb/context.rb:218
c:0018 p:0030 s:0058 b:0058 l:001cec d:000057 BLOCK  /usr/lib/ruby/1.9.1/irb.rb:157
c:0017 p:0039 s:0050 b:0050 l:000049 d:000049 METHOD /usr/lib/ruby/1.9.1/irb.rb:271
c:0016 p:0011 s:0045 b:0045 l:001cec d:000044 BLOCK  /usr/lib/ruby/1.9.1/irb.rb:154
c:0015 p:0132 s:0041 b:0041 l:000024 d:000040 BLOCK  /usr/lib/ruby/1.9.1/irb/ruby-lex.rb:244
c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC  :loop
c:0012 p:0009 s:0033 b:0033 l:000024 d:000032 BLOCK  /usr/lib/ruby/1.9.1/irb/ruby-lex.rb:230
c:0011 p:---- s:0031 b:0031 l:000030 d:000030 FINISH
c:0010 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC  :catch
c:0009 p:0023 s:0025 b:0025 l:000024 d:000024 METHOD /usr/lib/ruby/1.9.1/irb/ruby-lex.rb:229
c:0008 p:0042 s:0022 b:0022 l:001cec d:001cec METHOD /usr/lib/ruby/1.9.1/irb.rb:153
c:0007 p:0011 s:0019 b:0019 l:000644 d:000018 BLOCK  /usr/lib/ruby/1.9.1/irb.rb:70
c:0006 p:---- s:0017 b:0017 l:000016 d:000016 FINISH
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 CFUNC  :catch
c:0004 p:0174 s:0011 b:0011 l:000644 d:000644 METHOD /usr/lib/ruby/1.9.1/irb.rb:69
c:0003 p:0039 s:0006 b:0006 l:0018c4 d:001af4 EVAL   /usr/bin/irb1.9.1:12
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0018c4 d:0018c4 TOP   
---------------------------
-- Ruby level backtrace information-----------------------------------------
/var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wx.rb:12:in `require'
/var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wx.rb:12:in `'
(irb):1:in `require'
(irb):1:in `irb_binding'
/usr/lib/ruby/1.9.1/irb/workspace.rb:80:in `eval'
/usr/lib/ruby/1.9.1/irb/workspace.rb:80:in `evaluate'
/usr/lib/ruby/1.9.1/irb/context.rb:218:in `evaluate'
/usr/lib/ruby/1.9.1/irb.rb:157:in `block (2 levels) in eval_input'
/usr/lib/ruby/1.9.1/irb.rb:271:in `signal_status'
/usr/lib/ruby/1.9.1/irb.rb:154:in `block in eval_input'
/usr/lib/ruby/1.9.1/irb/ruby-lex.rb:244:in `block (2 levels) in each_top_level_statement'
/usr/lib/ruby/1.9.1/irb/ruby-lex.rb:230:in `loop'
/usr/lib/ruby/1.9.1/irb/ruby-lex.rb:230:in `block in each_top_level_statement'
/usr/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `catch'
/usr/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `each_top_level_statement'
/usr/lib/ruby/1.9.1/irb.rb:153:in `eval_input'
/usr/lib/ruby/1.9.1/irb.rb:70:in `block in start'
/usr/lib/ruby/1.9.1/irb.rb:69:in `catch'
/usr/lib/ruby/1.9.1/irb.rb:69:in `start'
/usr/bin/irb1.9.1:12:in `
' -- C level backtrace information ------------------------------------------- 0x6c7929 /usr/lib/libruby-1.9.1.so.1.9(rb_vm_bugreport+0x69) [0x6c7929] 0x5e092f /usr/lib/libruby-1.9.1.so.1.9(+0x4692f) [0x5e092f] 0x5e09ca /usr/lib/libruby-1.9.1.so.1.9(rb_bug+0x3a) [0x5e09ca] 0x5e0f0c /usr/lib/libruby-1.9.1.so.1.9(rb_check_type+0xbc) [0x5e0f0c] 0x12a2cdc /var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wxruby2.so(Init_wxAboutDialogInfo+0x8c) [0x12a2cdc] 0x16da1fb /var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wxruby2.so(InitializeOtherModules+0xb) [0x16da1fb] 0x16db109 /var/lib/gems/1.9.1/gems/wxruby-2.0.1-x86-linux/lib/wxruby2.so(Init_wxruby2+0x339) [0x16db109] 0x5b722a /usr/lib/libruby-1.9.1.so.1.9(dln_load+0x10a) [0x5b722a] 0x5e4ae8 /usr/lib/libruby-1.9.1.so.1.9(+0x4aae8) [0x5e4ae8] 0x6b34ef /usr/lib/libruby-1.9.1.so.1.9(rb_vm_call_cfunc+0xaf) [0x6b34ef] 0x5e5ad7 /usr/lib/libruby-1.9.1.so.1.9(rb_require_safe+0x5d7) [0x5e5ad7] 0x5e5e06 /usr/lib/libruby-1.9.1.so.1.9(rb_f_require+0x26) [0x5e5e06] 0x6b4af3 /usr/lib/libruby-1.9.1.so.1.9(+0x11aaf3) [0x6b4af3] 0x6b4e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0x6b4e84] 0x6c117c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0x6c117c] 0x6bb673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0x6bb673] 0x6beb46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0x6beb46] 0x6bef0a /usr/lib/libruby-1.9.1.so.1.9(rb_iseq_eval+0x12a) [0x6bef0a] 0x5e4c8d /usr/lib/libruby-1.9.1.so.1.9(rb_load+0x18d) [0x5e4c8d] 0x5e5b18 /usr/lib/libruby-1.9.1.so.1.9(rb_require_safe+0x618) [0x5e5b18] 0x5e5e06 /usr/lib/libruby-1.9.1.so.1.9(rb_f_require+0x26) [0x5e5e06] 0x6b4af3 /usr/lib/libruby-1.9.1.so.1.9(+0x11aaf3) [0x6b4af3] 0x6b4e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0x6b4e84] 0x6c117c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0x6c117c] 0x6bb673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0x6bb673] 0x6beb46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0x6beb46] 0x6bfb1f /usr/lib/libruby-1.9.1.so.1.9(+0x125b1f) [0x6bfb1f] 0x6c014c /usr/lib/libruby-1.9.1.so.1.9(rb_f_eval+0xdc) [0x6c014c] 0x6b4b18 /usr/lib/libruby-1.9.1.so.1.9(+0x11ab18) [0x6b4b18] 0x6b4e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0x6b4e84] 0x6c117c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0x6c117c] 0x6bb673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0x6bb673] 0x6beb46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0x6beb46] 0x6c0640 /usr/lib/libruby-1.9.1.so.1.9(+0x126640) [0x6c0640] 0x5e2379 /usr/lib/libruby-1.9.1.so.1.9(rb_rescue2+0x169) [0x5e2379] 0x6b670c /usr/lib/libruby-1.9.1.so.1.9(+0x11c70c) [0x6b670c] 0x6b4afd /usr/lib/libruby-1.9.1.so.1.9(+0x11aafd) [0x6b4afd] 0x6b4e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0x6b4e84] 0x6c117c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0x6c117c] 0x6bb673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0x6bb673] 0x6beb46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0x6beb46] 0x6bf146 /usr/lib/libruby-1.9.1.so.1.9(+0x125146) [0x6bf146] 0x6bf912 /usr/lib/libruby-1.9.1.so.1.9(+0x125912) [0x6bf912] 0x6b4b18 /usr/lib/libruby-1.9.1.so.1.9(+0x11ab18) [0x6b4b18] 0x6b4e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0x6b4e84] 0x6c117c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0x6c117c] 0x6bb673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0x6bb673] 0x6beb46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0x6beb46] 0x6bf146 /usr/lib/libruby-1.9.1.so.1.9(+0x125146) [0x6bf146] 0x6bf912 /usr/lib/libruby-1.9.1.so.1.9(+0x125912) [0x6bf912] 0x6b4b18 /usr/lib/libruby-1.9.1.so.1.9(+0x11ab18) [0x6b4b18] 0x6b4e84 /usr/lib/libruby-1.9.1.so.1.9(+0x11ae84) [0x6b4e84] 0x6c117c /usr/lib/libruby-1.9.1.so.1.9(+0x12717c) [0x6c117c] 0x6bb673 /usr/lib/libruby-1.9.1.so.1.9(+0x121673) [0x6bb673] 0x6beb46 /usr/lib/libruby-1.9.1.so.1.9(+0x124b46) [0x6beb46] 0x6bedbb /usr/lib/libruby-1.9.1.so.1.9(rb_iseq_eval_main+0xab) [0x6bedbb] 0x5e2c77 /usr/lib/libruby-1.9.1.so.1.9(ruby_exec_node+0xb7) [0x5e2c77] 0x5e4276 /usr/lib/libruby-1.9.1.so.1.9(ruby_run_node+0x56) [0x5e4276] 0x80487c8 irb1.9.1(main+0x68) [0x80487c8] 0x325bd6 /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0x325bd6] 0x80486c1 irb1.9.1() [0x80486c1] [NOTE] You may encounter a bug of Ruby interpreter. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html Aborted

Friday, December 3, 2010

Ubuntu update failed and it did not start - the filesystem does not have /sbin/init

I started normal updates through Update Manager for my Ubuntu 10.04 but it failed: just hang up in the middle of it. I had to physically shutdown the machine. And what I was afraid did happened. The Ubuntu failed to start. It did go through grub and then got an error that said.
The target filesystem doesn't have /sbin/init
No init found. Try passing init=bootarg
...

1. Retart in Recovery Mode
The first I tried to start with RECOVERY MODE that gave me an option to try to automatically fix the error. It did not fix, but it gave me an important information: which disk is having a problem. I have 4 x 1TB disks, one of which is a Window Vista. I needed to know exactly which disk to fix.
fsck from util-linux-ng 2.17.2
.....
/dev/sdd1 contains a file system with errors, check forced.
/dev/sdd1 I***s that were part of a corrupted orphan linked list found.
/dev/sdd1 UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
(i.e., without -a or -p options)
mount all: fsck / [430] terminated with status 4
mount all: Filesystem has errors: /
So, the problem resides in /dev/sdd1.

2. Restart with Live CD and Fix with e2fsck
a. Backup my files.
After booting up with a Live CD, I mounted all drives and backed up my home directory from File System drive to another drive - just in case.
b. Unmount all drives.
Before running e2fsck, I unmounted all drives.
c. Run e2fsck.
$ sudo e2fsck -f -y -v /dev/sdd1
e2fsck 1.41.11 (14-Mar-2010)
Pass 1: Checking iノードs, blocks, and sizes
Pass 2: Checking ディレクトリ structure
Pass 3: Checking ディレクトリ connectivity
Pass 4: Checking reference counts
Pass 5: Checking グループ summary information

  309128 inodes used (0.51%)
     409 non-contiguous files (0.1%)
     329 non-contiguous directories (0.1%)
         # of inodes with ind/dind/tind blocks: 0/0/0
         Extent depth histogram: 279193/243
35484518 blocks used (14.68%)
       0 bad blocks
       1 large file

  238984 regular files
   33026 directories
      60 character device files
      26 block device files
       5 fifos
     507 links
   36963 symbolic links (29536 fast symbolic links)
      55 sockets
--------
  309626 files

3. Restart the machine.
It started without problem.


4. Rererences
http://wwww.ubuntuforums.org/showthread.php?t=1167710
ttp://wwww.ubuntuforums.org/showthread.php?t=1594621h