Monday, February 13, 2012

ERROR: ActiveRecord oracle_enhanced adapter could not load ruby-oci8 library. Please install ruby-oci8 gem.

If you are facing an error on ubuntu while connecting oracle even though you have installed ruby-oci8 and activerecord-oracle_enhanced_adapter you need install following library.


ERROR: ActiveRecord oracle_enhanced adapter could not load ruby-oci8 library. Please install ruby-oci8 gem.

sudo apt-get install libaio1

I hope this should work for you.

Saturday, September 10, 2011

installing mysql gem on ubuntu + ERROR: Error installing mysql

If you are facing below issue while installing mysql gem on ubuntu then you need to install 'libmysqlclient-dev' library.

manohar@manohar-Inspiron-1525:~$ gem install mysql
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

        /home/manohar/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:

Use below command to resolve above issue-

manohar@manohar-Inspiron-1525:~$ sudo apt-get install libmysqlclient-dev

Wednesday, August 17, 2011

Ruby on Rails Development Platform in Enterprise

Ruby on Rails is growing in enterprises in India, but they are still lagging with popular development platforms like Mac or linux. As it's difficult for them to afford Mac and they cannot use Linux based Operating Systems (OS) on host machines due to security constraints or to use some windows based apps. So I decided to use Virtual Machine on my Windows based Host System.

Here is configuration of my host system:
Processor: Intel Core 2 Duo CPU, RAM: 2GB, Operating System: Windows 7 Enterprise

Now To use Ubuntu (Linux based OS) with above configuration, follow below steps-

1. Download and Install VMWare Player which is free for personal non-commercial use. VMware Player is only distributable with written permission from VMware. So don't share the exe/setup, download it separately.

2. Download ISO of Ubuntu.

3. Create a New Virtual Machine for Ubuntu using VMware Player. Just follow 'Next' Its simple. It takes default 512 MB of RAM but I did allocate 896 MB of RAM as I had 2 GB of RAM. (It might install required files.)

Now you have Ubuntu ready on your windows based system. To install Ruby and Rails using RVM please follow below steps-

1. To install RVM you need git. Run below command to install git-
ubuntu@ubuntu:~$ sudo apt-get install git
And then follow installation steps for RVM here.
Run below command in terminal-
ubuntu@ubuntu:~$ bash < <(curl -s
And then follow steps mentioned in output of above command to update .bashrc.

2. After installing RVM successfully follow below steps to install ruby and rails. Steps mentioned below are used to avoid the issue mentioned here.
ubuntu@ubuntu:~$ rvm pkg install zlib
ubuntu@ubuntu:~$ rvm pkg install openssl
ubuntu@ubuntu:~$ rvm install 1.8.7 -C --with-openssl-dir=$rvm_path/usr  --with-zlib-dir=$rvm_path/usr

3. Create new gemset using rvm.
ubuntu@ubuntu:~$ rvm gemset create rails_3

4. Check available version of ruby and gemset.
ubuntu@ubuntu:~$ rvm list
ubuntu@ubuntu:~$ rvm gemset list

5. Set default versions of Ruby and Rails using rvm. I am using ruby-1.8.7-p352@rails_3 as I have installed ruby 1.8.7 and created gemset named as rails_3.
ubuntu@ubuntu:~$ rvm use --default ruby-1.8.7-p352@rails_3

6. Now you can install rails.
ubuntu@ubuntu:~$ gem install rails

You are ready with ruby and rails, Now you need database. You can simply install mysql or postgresql using apt-get install command or from ubuntu software center.

I wanted to use Oracle but I didn't install it on my ubuntu system (virtual machine) as it's running less than 1 GB RAM which is kind of minimum requirement for oracle database. And I have already installed Oracle XE on my host system so I am going to use it using Host IP address in my database.yml of rails app.

To use oracle I need to install ruby-oci8 and activerecord-oracle_enhanced-adapter gems.

1. Follow steps here to install ruby-oci8 using InstantClient.

2. If you are facing any issues to install gem ruby-oci8, you have to set path for LD_LIBRARY_PATH in your .bashrc. Eg: export LD_LIBRARY_PATH="/opt/oracle/instantclient_11_2"

Apart from these you have to install few required libraries and application like tortoisesvn, NetBeans(IDE) etc. Currently I am using Ubuntu just by using 896MB of RAM and it works fine.

Few things to remember while using this combination-

1. Increase RAM size allocated from 512MB, if you are going to use NetBeans as it takes bit lot memory.

2. Increase number of Processors to 2 if you have core 2 Duo, Default its set to only 1. It really helps.

3. From Virtual Machine Settings -> Hardware -> CD/DVD Device, dis-select 'Connect at power on' check box as you may not have CD-ROM available.

4. CTRL+G is used to enter into Virtual Machine and CTRL+ALT get out of it.
    CTRL+ALT+DELETE call is taken by both Virtual Machine and host system. So make sure you will be using host system if you want to lock it.

You can use-  Name: CTRL+ALT_DELETE  and Command: gnome-editor 

6. If you want to have shared folder between host system and virtual system, refer the article here to update Virtual Machine Tools first and then you can simply add folders from Virtual Machine Settings -> Options -> Shared Folders. You will get them in /mnt/hgfs

Note: I was using a network where I was able to download all required software.

Saturday, July 30, 2011

no such file to load -- zlib

If you have installed rvm and then ruby and now facing below issue while installing rails-
manohar@manohar-Inspiron-1525:~$ gem install rails
ERROR:  Loading command: install (LoadError)
no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand

Below steps should fix your problem as it worked for me.

$ rvm pkg install zlib
$ rvm remove 1.9.2
$ rvm install 1.9.2 --with-zlib-dir=$rvm_path/usr


If you need to use you might face below problem after installing heroku gem and running heroku commands:

no such file to load -- net/https.
Try running apt-get install libopenssl-ruby (LoadError)
Below steps will work:
$ rvm remove 1.9.2 
$ rvm pkg install openssl
$ rvm install 1.9.2 -C --with-openssl-dir=$rvm_path/usr
And to resolve both zlib and libopenssl problem use below steps:

$ rvm remove 1.9.
$ rvm pkg install zlib
$ rvm pkg install openssl
$ rvm install 1.9.2 -C --with-openssl-dir=$rvm_path/usr  --with-zlib-dir=$rvm_path/usr

Sunday, June 12, 2011

meta-design patterns

  • Separate out the things that change from those that stay the same.
  • Program to an interface, not an implementation.
  • Prefer composition over inheritance.
  • Delegate, delegate, delegate.

Thursday, June 9, 2011

big fan of Yehuda's open source contributions

Yehuda Katz is a member of the SproutCore, Ruby on Rails and jQuery Core Teams; during the daytime, he works as an architect at Strobe. Yehuda is the co-author of the best-selling "jQuery in Action", the upcoming "Rails 3 in Action", and is a contributor to "Ruby in Practice". He spends most of his time hacking on open source - his main projects, along with others, like Thor, Handlebars and Janus - or traveling the world doing evangelism work. He blogs at and can be found on Twitter as @wycats.
And I am huge fan of his open source contributions, they could be from server side or client side or any other library and I had wish to have a snap with this great contributor which I completed in RubyConf India 2011.


Monday, May 23, 2011

Exception in thread "main" java.lang.NoClassDefFoundError + running sunspot:solr:run on windows

While running "sunspot:solr:run" on Windows ["sunspot:solr:run" works with windows otherwise use "sunspot:solr:start"] if you are receiving error like -
Exception in thread "main" java.lang.NoClassDefFoundError: 
Caused by: java.lang.ClassNotFoundException:
  at$ Source)
  at Method)
  at Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: 
  Program will exit.  
Please change line no. 74 in server.rb from lib of sunspot gem, 
with "exec(Escape.shell_command(command).gsub("'",'"'))"
For details refer source.