Something weird is going on. Instead of #!/usr/bin/ruby
, I had to make it #!/usr/local/bin/ruby
.
I had to make similar changes in ruby interpreter setting in eclipse. Now my code is working fine.
So, Now I realized I actually have two versions of ruby installed:
# /usr/bin/ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
# /usr/local/bin/ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [i686-linux]
I don't know how the version 2.0.0
got installed.
I had installed only 1.9.2
. and then ran gem install awesome_print
So, if I change the shebang
and eclipse
to use the ruby 2.0.0
, it is working fine. Probably, my awesome_print
got installed only for 2.0.0
This is so confusing. Anyway. I am good now. Ruby learning !!!
But then again, how come I was able to run the same program fine from command line even with ruby verion 1.9.2
?
UPDATE:
So, I was wrong, When I ran ruby array.rb
it was actually running /usr/local/bin/ruby
and hence it worked from the command line. But in eclipse, I had set the ruby interpreter as /usr/bin/ruby
which was 1.9.2.
and it was giving errors.
I could reproduce the same error from command line by running /usr/bin/ruby array.rb
.
So...
This means, my installation of ruby 1.9.2 is not good. I still don't know where ruby 2.0.0
came from. But Now, I should uninstall and get rid of 1.9.2
.