Deprecated Warning

This blog is unmaintained, I leave the contents here just for archives. My current blog: http://bambangpdp.wordpress.com.

Rubygems 0.9.5 and Rails 1.2.6 – uninitialized constant Gem::GemRunner

This morning I update my Rails installation to 1.2.6 and that is why I need to have a new local copy of Rails 1.2.6 API documentation. I usually get my local API documentation using these steps:

  1. rails dummy
  2. cd dummy
  3. rake rails:freeze:gems
  4. rake doc:rails
  5. mv doc/api ~/docs/ruby/rails/

and then I have my local API docs at $HOMOE/docs/ruby/rails/api/

That was when everything worked fine. This morning, those steps result error which I suspect from gem:

uninitialized constant Gem::GemRunner

So I began searching. Luckily I found this:

http://groups.google.com/group/rubyonrails-core/browse_thread/thread/d3e96496eca8735c

Then I edited this file:

$GEM-HOME/gems/rails-1.2.6/lib/tasks/framework.rake

and add require ‘rubygems/gem_runner’ between these lines:

      deps = %w(actionpack activerecord actionmailer activesupport actionwebservice)
      require 'rubygems'
      require 'rubygems/gem_runner'
      Gem.manage_gems

Everything runs well now🙂

UnDip seminar – Web 2.0 Security

Saturday, 26th Nov 2007 I gave presentation at Diponegoro University, Faculty of Engineering about Web 2.0 Securty. My presentation paper available upon request although I will keep it at SlideShare someday.

So you use acts_as_authenticated and don’t want to lose other session var when logout?

I’ve just wrote this trivial tips:

http://technoweenie.stikipad.com/plugins/show/Logout+without+losing+other+session+variables

PayPal API credentials problem

For those of you who will start using PayPal, have a look at this this link:

Now I can have API credentials so that I can use it for my first Rails e-commerce site.

Thanks Rob!

Just for the record, I will keep it here. Credits should goes to CitrusUser / Rob

After 6 hours of pain with PayPal support (or lack thereof) I present the following 30 step process to creating, confirming, and verifying test accounts through the broken Developer Central Sandbox.

I hope this helps other people, and that the years of life I've lost over the last several hours is worth it.

To Setup Sandbox and Get Test API Credentials:

Prerequisites:
* Create a user account to access the Developer Central Sandbox.
* Log in to the Sandbox account
* Create a Test Account of type 'seller'. 
 - This will throw an error message on saving, but it will still create the account.  Click the Test Accounts tab to see the account it created.

Create Confirm the email address:
1. Create business test account (done in prerequisite above)
2. Log into PayPal Sandbox with test business account details created earlier.
3. Go to Profile Tab
4. Go to Email
5. Choose the email address and click 'Confirm'
6. Go back to the Sandbox Test Environment and click the Test Email tab
7. Open the email with subject line 'Activate Your PayPal Account'
8. From the email body, select the confirmation URL and paste into new browser window - it will load the PayPal site (in sandbox mode).
9. Log in with business account.
10. From the landing page, click the 'confirm email' link in the 'To Do List' box.
11. Click the 'click here if a link doesn't appear in the email' link.
12. Paste in the confirmation number from the email in step 8, and click confirm.  A confirmation of success should be displayed.
13. Click Continue.

Create Bank Accounts For Test Business Account:
14. Click the Profile tab
15. Click Bank Accounts link
16. Create a fake bank account. Test Bank.  Use BSB 242-200 for Australia.  Any random integer for account number, so long as it's not already being used by another PayPal account.  I ended up having to mash the keypad until I found an unused number.
17. Confirm the bank account by clicking the 'confirm' link after the step above.
18. Step 17 loads another page where you need to click 'Submit'.
19. Step 18 loads another page where you need to click 'I Agree'.
20. The account should now be verified.
21. Click the Profile Tab again.
22. Click API Setup
23. Click Request API Credentials
24. Select API Signature
25. Click I Agree, Click Submit.
26. Copy the details to a safe place for later reference.

Developer Central Sandbox
27. Go back to the Developer central sandbox and login with your account details created in the prerequisite section of this document (i.e., not your test business account, but your actual Developer Central Sandbox account).
28. The Test business account should now be verfied.
29. Click API Credentials tab.
30. The API credentials obtained in step 26 should appear.

Cheers,
Rob.

What does “/…../mongrel.rb:15: warning: already initialized constant OPTIONS” means?

It turns out that our Rails installation has a problem cause I always got those error message when I tried to start server. Here is the complete logs if you’re curious:

bpdp@akakom:~/src/tbar$ script/server webrick
=> Booting WEBrick...
/opt/software/ruby/gems/rails-1.2.3/lib/commands/servers/webrick.rb:11: warning: already initialized constant OPTIONS
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
Exiting
/opt/software/ruby/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:15: warning: already initialized constant OPTIONS
/opt/software/ruby/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:18: undefined method `options' for []:Array (NoMethodError)
        from /opt/software/ruby//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `gem_original_require'
        from /opt/software/ruby//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `require'
        from /opt/software/ruby/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require'
        from /opt/software/ruby/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
        from /opt/software/ruby/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require'
        from /opt/software/ruby/gems/rails-1.2.3/lib/commands/server.rb:39
        from /opt/software/ruby//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `gem_original_require'
        from /opt/software/ruby//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `require'
        from script/server:3
bpdp@akakom:~/src/tbar$

So I started to find the solution online, but none helps. Some posts said that this error showed up because Rails can not find dependenc{y/ies} for some of its plugins. Hmm … ok, then it looks like I have to manually search for every plugins’ dependencies and then install them.

How to do that?

Easy. All I have to do is remove all of the plugins (I just move it to directory $RAILS_ROOT/tmp/plugins which I created myself) and then start move it one by one to $RAILS_ROOT/vendor/plugins and test it using $RAILS_ROOT/script/server webrick.

Then I found that activemerchant is my problem. I need builder gem.

It’s all easy but the error messages was really a mess🙂

Java, JRuby, Rails dan Netbeans di NexentaOS

Hari ini berhasil juga install JDK. Kuncinya ternyata sederhana saja, jgn pakai /usr/bin/sh yang merupakan symlink ke bash untuk menjalankan binary sh yang di download dari Sun. Saya nggak tau juga kenapa bisa begitu. Kalau menggunakan /usr/bin/sh, hasil extract akan dianggap corrupt. Untung saja saya menemukan infonya di http://www.gnusolaris.org/phpbb/viewtopic.php?t=5817&sid=ae4a6c783d950c98e573e4cf6eecff54.

Agak lucu juga sih kalau NexentaOS yang menggunakan kernel OpenSolaris ternyata tidak menyediakan JDK. Repository APT hanya menyediakan JRE (sunwjre1.5), jadi saya pakai saja yang self-extract dari java.sun.com.

Setelah berhasil, saya mensetting variable yang diperlukan di satu file environment variabel:

JAVA_HOME=/export/home/bpdp/software/jdk1.5.0_12
export JAVA_HOME

PATH=$PATH:$JAVA_HOME/bin
export PATH

MANPATH=$MANPATH:$JAVA_HOME/man
export MANPATH

Jadi, setiap kali  memerlukan jdk, tinggal source saja ke file itu. Beres.

Ok, sekarang karena JDK sudah ok, saya pengin nyoba IDEnya Rails yang di Netbeans. Meskipun baru M10, rasanya nggak rugi dicoba😀. Edisi yang mengandung JRuby/Rails harus edisi full, jadi saya ambil edisi full untuk Solaris (netbeans-6.0m10-full-solaris-x86.sh) dan mulai menginstall. Kali ini /usr/bin/sh bekerja dengan baik😀.

Meskipun belum mencoba secara keseluruhan, I am impressed. Works like a charm. Ini nih screenshoot dari Netbeans 6.0 – m10.

Netbeans 6.0 - M10 di NexentaOS

Ruby dan Rails di NexentaOS

Setelah sekian lama penasaran, akhirnya saya mendapatkan kesempatan dan waktu untuk install OpenSolaris. Penyakit gatal saya ini kumat gara-gara BeleniX, salah satu distro dari OpenSolaris merilis versi 0.6.1. Setelah mengambil ISO, saya mencoba LiveCD dari BeleniX dan nekad menghapus Arch Linux di komputer saya.

Mulanya saya kira bakal sulit, hmm … ternyata LiveCD BeleniX langsung saja jalan dengan mulus, termasuk DHCP, sound card, dan monitor (1280×1024). Sayangnya, software yang ada di dalamnya bukan software yang bleeding-edge. Nah karena membayangkan instalasi bakal gampang, jadi saya nekad saja menggunakan perintah untuk install:

hdinstaller

Setelah menunggu sekitar 20 menit, instalasi selesai. Ternyata proses berikutnya tidak semulus yang dibayangkan😀. Pada saat create normal user, hdinstaller crash. Waduh, saya nekad saja reboot dengan perasaan tidak berdaya😀. Lha gimana lagi, wong belum pernah pakai OpenSolaris, blas nggak akrab. Setelah reboot ternyata nggak bisa booting dari harddisk (karena multiboot tidak digunakan lagi). Setelah memeriksa ke situs yang disarankan pada saat booting dan mengubah GRUB, ternyata tetap tidak bisa. Hmm … ok, jadi saya memutuskan untuk tidak pakai BeleniX.

Gara-gara BeleniX tidak bisa dan sudah terlanjur terobsesi dengan OpenSolaris, akhirnya ambil ISO Elatte Alpha7 milis Nexenta dan saya install. Instalasi memang gampang karena saya pakai semua harddisk dan auto layout. Menurut beberapa artikel yang saya baca (ada URLnya di web Nexenta), proses partisi manual relatif “unpleasant”. Akhirnya setelah mengikuti petunjuk di wiki Nexenta, komputer saya sekarang menggunakan NexentaOS.

Oh ya, ada beberapa pelajaran yang bisa dipetik dari instalasi Nexenta:

  • Jangan mengubah /etc/apt/sources.list ke unstable. Proses ini hanya akan menghasilkan broken packages dan jika digunakan apt-get -f install, GNOME akan di-remove😀.
  • Xorg menggunakan konfigurasi built-in, jadi tidak ada xorg.conf. Saya menggunakan Xorg -configure untuk menghasilkan xorg.conf.new di $HOME dan mengedit resolusi monitor (tepatnya: menambahkan) menjadi 1280×1024 karena konfigurasi builtin menggunakan 1400×1050 yang di monitor LG Flatron L1753S saya terlalu besar.

Berikut ini adalah isi lengkap xorg.conf:


Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
RgbPath "/etc/X11/rgb"
ModulePath "/usr/lib/xorg/modules"
FontPath "/usr/share/X11/fonts/misc/"
FontPath "/usr/share/X11/fonts/TTF/"
FontPath "/usr/share/X11/fonts/OTF"
FontPath "/usr/share/X11/fonts/Type1/"
FontPath "/usr/share/X11/fonts/CID/"
FontPath "/usr/share/X11/fonts/100dpi/"
FontPath "/usr/share/X11/fonts/75dpi/"
EndSection

Section "Module"
Load "extmod"
Load "dbe"
Load "glx"
Load "record"
Load "xtrap"
Load "freetype"
Load "type1"
EndSection

Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
EndSection

Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/mouse"
Option "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
#DisplaySize 340 270 # mm
Identifier "Monitor0"
VendorName "GSM"
ModelName ""
### Comment all HorizSync and VertSync values to use DDC:
HorizSync 30.0 - 83.0
VertRefresh 56.0 - 75.0
Option "DPMS"
EndSection

Section "Device"
Identifier "Card0"
Driver "ati"
VendorName "ATI Technologies Inc"
BoardName "RV370 5B60 [Radeon X300 (PCIE)]"
BusID "PCI:2:0:0"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
SubSection "Display"
Viewport 0 0
Depth 1
Modes "1280x1024"
EndSubSection
SubSection "Display"
Viewport 0 0
Depth 4
Modes "1280x1024"
EndSubSection
SubSection "Display"
Viewport 0 0
Depth 8
Modes "1280x1024"
EndSubSection
SubSection "Display"
Viewport 0 0
Depth 15
Modes "1280x1024"
EndSubSection
SubSection "Display"
Viewport 0 0
Depth 16
Modes "1280x1024"
EndSubSection
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1280x1024"
EndSubSection
EndSection

Setelah semua beres, sekarang tiba waktunya untuk Ruby dan Rails. Instalasi dari source code ternyata tidak bermasalah.


bpdp@bpdp-nexenta:~$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-solaris2.11]
bpdp@bpdp-nexenta:~$ psql --version
psql (PostgreSQL) 8.1.9
contains support for command-line editing
bpdp@bpdp-nexenta:~$ rails -v
Rails 1.2.3
bpdp@bpdp-nexenta:~$ gem --version
0.9.4
bpdp@bpdp-nexenta:~$ gem list --local

*** LOCAL GEMS ***

actionmailer (1.3.3)
Service layer for easy email delivery and testing.

actionpack (1.13.3)
Web-flow and rendering framework putting the VC in MVC.

actionwebservice (1.2.3)
Web service support for Action Pack.

activerecord (1.15.3)
Implements the ActiveRecord pattern for ORM.

activesupport (1.4.2)
Support and utility classes used by the Rails framework.

cgi_multipart_eof_fix (2.1)
Fix an exploitable bug in CGI multipart parsing which affects Ruby
<= 1.8.5 when multipart boundary attribute contains a non-halting
regular expression string.

daemons (1.0.7)
A toolkit to create and control daemons in different ways

fastthread (1.0)
Optimized replacement for thread.rb primitives

gem_plugin (0.2.2)
A plugin system based only on rubygems that uses dependencies only

mongrel (1.0.1)
A small fast HTTP library and server that runs Rails, Camping, Nitro
and Iowa apps.

postgres (0.7.1)
The extension library to access a PostgreSQL database from Ruby.

rails (1.2.3)
Web-application framework with template engine, control-flow layer,
and ORM.

rake (0.7.3)
Ruby based make-like utility.

sources (0.0.1)
This package provides download sources for remote gem installation
bpdp@bpdp-nexenta:~$

Hmm … life is beautiful, isn’t it?

Akhirnya berhasil juga install Instiki

 Dengan menggunakan petunjuk dari Carsten Andersen di  http://www.instiki.org/show/Debian, akhirnya Instiki terinstall di http://www.akakom.ac.id:8080/.

Ternyata hanya semudah menghapus seluruh isi direktori vendor (😀 )

XRails uploaded to Rubyforge

Have a look here: http://rubyforge.org/projects/xrails/

This first release (development, ’cause probably it still unstable and I will patch it later or get any other ruby modules or maybe any other software like capistrano) uses Rails version numbering. So, I give version number 1.2.3, the same with latest Rails.

On this release: x86 (for i386) and x86_64 (for AMD64).