Thursday, May 29, 2014

C extension support is not enabled. [pry-stack_explorer]

If you are using pry then you may looks for better pry debugger plugins . I faced the above issue when I used to install pry-stack_explorer. The complete error you can find here :

https://www.ruby-forum.com/topic/4832612#new

In my case I am using pry-nav and pry-stack_explorer combined to debug the code. Please follow the below steps to install the above plugins.

1) install jruby-1.7.8, Export the variable JRUBY_HOME and PATH
NOTE : explicitly export this variable as we are going to use it once.
export JRUBY_OPTS=-Xcext.enabled=true

2) install ruby-1.9
NOTE : Here we need ruby-1.9 only for libraries, So you can set the --prefix at the time of
configuration and install in you specified directory.

3) create directory structure in JRUBY_HOME/lib/native/include

4) create soft link in JRUBY_HOME/lib/native/include
 ln -s RUBY_HOME/include/ruby-1.9.1/ruby ruby

5) jruby -S gem install pry-nav

6) jruby -S gem install pry-stack_explorer

that's it .

Please suggests if any body have any better tricks or idea.


Thanks
-Khirod





Tuesday, May 20, 2014

cannot load Java class jline.console.ConsoleReader

Please follow the link for more information.

https://www.ruby-forum.com/topic/4816085#new

-Khirod

Friday, April 25, 2014

eclipse icon issue in ubuntu 12.04



  1. Install gnome-desktop if it is not there 
  2. Execute the command gnome-desktop-item-edit --create-new ~/Desktop
  3. click on the icon on left top side of the pop up box and set the for icon.xpm where eclipse edittor unzipped
  4. set the application path
Now it is ready to run eclipse from your Desktop luncher.



-Khirod

Saturday, February 15, 2014

ssh login without password

1)  Install ssh on both Host , we will take as client1 and client2 . Here client1 will login to client2 through ssh without password.

2)from client1:
cd ~
ssh-keygen -t rsa

Enter file in which to save the key (/home/client1/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/kshyama/.ssh/id_rsa.
Your public key has been saved in /home/kshyama/.ssh/id_rsa.pub.
The key fingerprint is:
da:0d:08:10:8c:e6:59:2d:b0:59:8d:cf:3f:bd:70:e6 kshyama@kshyama
The key's randomart image is:
+--[ RSA 2048]----+
| ooo..+          |
|....++ o         |
|o  oo +          |
| . . . +         |
|  .   . S .      |
|       o * +     |
|      . . B .    |
|           E     |
|                 |
+-----------------+


3)cat .ssh/id_rsa.pub | ssh client2@192.168.3.20 'cat >> .ssh/authorized_keys'

Now you are done. The ssh connection will not ask any password from client1 to client2

Tuesday, January 14, 2014

[JRUBY] NameError: uninitialized constant Net::SSH::Connection::Session::JavaLang

I have gone through the work around for this issue successfully , but still not sure if it is a bug of net/ssh gem

Error Details :

NameError: uninitialized constant Net::SSH::Connection::Session::JavaLang
   const_missing at org/jruby/RubyModule.java:2642


The above error encountered when my program tried to open a new channel session. It looks for JavaLang. I just simple add a module of JavaLang which use the package of java.lang and issue resolved. i.e.


require 'java'
require 'rubygems'
require 'net/ssh'


module JavaLang
  include_package "java.lang"
end

class Testing1
   
  def testConnection()
    Net::SSH.start("myhost","user_id", :password => "password" ) do |ssh|
       puts("Connection Established")
      ssh.open_channel do |channel|
        puts("SSH Channel opened successfully")
      end
    end
  end

end



-Khirod

Monday, December 10, 2012

Network File System (NFS)

Follow the below syntax to create a Network File System. Please Note you must have the Root access to do this anyway.

Let two host A and B both can be access to each other over the network and you want to create a NFS on B from A.

Example Case:

java installed on machine A and JAVA_HOME on Host A is : /home/java/jdk1.6.0_33 . and you want to use the java on machine B with out installing it on B

ON Host B :

1) create a directory java [Note you can crteate this directory anywhere]. I am taking /mnt as parent directory , so you must be root or you have the sudo access to do so

 ~]# mkdir /mnt/java

2)open the file /etc/fstab and append the below line . Please change the parameter as per your requirements

 ~]# vi /etc/fstab

A:/home/java/jdk1.6.0_33 /mnt/java nfs defaults 0 0

A : Host name or IP address
/home/java/jdk1.6.0_33 : Path on Host A
/mnt/java                       : Path on Host B


On Host A:

1) Open the file /etc/exports and append the below line. Please change the path as per your requirements.

~]# vi /etc/exports

/home/java/jdk1.6.0_33 *(rw,sync,no_root_squash)

2)Start the nfs service. The below command will stop and start the service

 ~]# service nfs restart

3) Start portmnp service

~]# service portmap restart



Final step on Host B:

~]# mount /mnt/java


Now you are done. you can set your JAVA_HOME and PATH on Host B using the path /mnt/java.


Friday, June 22, 2012

Add Ruby Gems to your Jruby Application

In two way you can add Ruby Gems to your JRuby application.

Case 1: In this case we will take the gems for ssh connections i.e. net-ssh. So what ever the gems you want to add in your application , 1st check the required dependencies for that gems. in this case for net-ssh we required

1)jruby-openssl
2)jruby-pageant

Steps:: Case 1:-

1)download the jruby-complete-XXXX.jar file . check with below link for the respective versions.

http://jruby.org/download

you can create a jruby-complete.jar file from source too.
            a) download the jruby source from http://jruby.org/download
                Ex:-  E:\jruby-src-1.6.7.2.zip

            b) unzip it to any local directory
                 Ex:- unzip  jruby-src-1.6.7.2.zip
                         It will create a directory  jruby-1.6.7.2
            c) download and unzip ant if ant is not on your system http://ant.apache.org/bindownload.cgi
            d) set the ANT_HOME and PATH for the ant.
            e) change current directory  to the unzip jruby source directory
                   cd E:\jruby-1.6.7.2
            f) ant jruby-complete

It will create a jruby-complete.jar file which is same as if you follow to download it from the repository link http://jruby.org/download

Let your final jruby-complete.jar file in E:\jruby\jruby-complete.jar

2)  Let download and get the required gems . use the following command to do so

To get jruby-openssl:

java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./jruby-openssl jruby-openssl --no-rdoc --no-ri

To get jruby-pageant:

java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./jruby-pageant jruby-pageant --no-rdoc --no-ri

To Get net-ssh :

java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./net-ssh net-ssh --no-rdoc --no-ri

Now you have all the gems in your current directory i.e. E:\jruby

3) Let push these gems to the jruby-complete.jar file

jar uf jruby-complete-1.6.7.2.jar -C jruby-openssl .
jar uf jruby-complete-1.6.7.2.jar -C jruby-pageant .
jar uf jruby-complete-1.6.7.2.jar -C net-ssh .

4)  Lets check if the gems pushed successfully or not

java -jar jruby-complete-1.6.7.2.jar -S gem list

*** LOCAL GEMS ***

bouncy-castle-java (1.5.0146.1)
jruby-openssl (0.7.7)
jruby-pageant (1.1.1 java)
net-ssh (2.5.2)
rake (0.8.7)
sources (0.0.1)

5)  Let's check if the gems are loading through require or not

java -jar jruby-complete-1.6.7.2.jar -S irb

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'net/ssh'
=> true
irb(main):003:0> exit

-------------------------------End of Case 1--------------------------------------------------------------------
NOTE : you can install and push the gems in a single command also , just use them in the same command syntax with space..
--------------------------------------------------------------------------------------------------------------------
WOW that's it . now all your gems in your jar file.


Steps - Case 2:

case 2 is the traditional one.

1) follow the same step no 1 from Case1
2) now you have the jruby-complete.jar file . and your current directory is
     E:\jruby
     create a directory structure E:\jruby\lib\gems\1.8

Note : Here I used the above path for a separate the gems directory . So it is completely depends on you how you manage your path.

3) java -jar jruby-complete.jar -S install jruby-openssl jruby-pageant net-ssh --no-ri --no-rdoc -i lib/gems/1.8

 The above command will install all the required gems described in the command in the defined path . So here you can replace your destination path


4) Set the GEM_PATH

set GEM_PATH=E:\jruby\lib\gems\1.8

In Linux : export GEM_PATH=`pwd`/lib/gems/1.8

5)  Now follow the Steps No 4 and 5 from Case 1 to get the result.

That's It

------------------------------------------End of Case 2--------------------------------------------------

- Khirod