Cucumber error while calling jruby script

Hi All ,

I am getting the below error while calling jruby code …

But without jruby my cucumber is working fine , please let me know how
to
call jruby code from cucumber ?

mselv2m1:nikeplus-running-ios mselv2$ cucumber features/java.feature
no such file to load – java (LoadError)
/Users/mselv2/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
gem_original_require' /Users/mselv2/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:inrequire’
/Users/Shared/Development/NikeBuild/nikeplus-running-ios/features/step_definitions/first_call.rb:1
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/cucumber-1.3.2/bin/…/lib/cucumber/rb_support/rb_language.rb:122:in
load' /Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/cucumber-1.3.2/bin/../lib/cucumber/rb_support/rb_language.rb:122:inload_code_file’
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/cucumber-1.3.2/bin/…/lib/cucumber/runtime/support_code.rb:180:in
load_file' /Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/cucumber-1.3.2/bin/../lib/cucumber/runtime/support_code.rb:83:inload_files!’
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/cucumber-1.3.2/bin/…/lib/cucumber/runtime/support_code.rb:82:in
each' /Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/cucumber-1.3.2/bin/../lib/cucumber/runtime/support_code.rb:82:inload_files!’
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/cucumber-1.3.2/bin/…/lib/cucumber/runtime.rb:183:in
load_step_definitions' /Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/cucumber-1.3.2/bin/../lib/cucumber/runtime.rb:42:inrun!’
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/cucumber-1.3.2/bin/…/lib/cucumber/cli/main.rb:47:in
execute!' /Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/cucumber-1.3.2/bin/cucumber:13 /Users/mselv2/.rvm/gems/ruby-1.8.7-p371/bin/cucumber:19:inload’
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/bin/cucumber:19
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/bin/ruby_noexec_wrapper:14
mselv2m1:nikeplus-running-ios mselv2$

Thanks ,
Muthu S. SR

Your “cucumber” binary is pointing at Ruby-1.8.7 or you haven’t switched
your RVM to point to JRuby. You can tell this is the case by the fact
that your backtrace is pointing at locations for “ruby-1.8.7-p371”.
Either switch to jruby in RVM, or if you have JRuby installed separately
from RVM you can always use: jruby -S cucumber features/java.feature

  • Josh

Yes , As you said cucumber is pointing to 1.8.7 ,so i have pointed RVM
to
point JRuby with the below command but getting the error

mselv2m1:nikeplus-running-ios mselv2$ export JRUBY_OPTS="–1.9"
mselv2m1:nikeplus-running-ios mselv2$ jruby -S cucumber
features/java.feature
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/gherkin-2.12.0/lib/gherkin/i18n.rb:8
warning: already initialized constant LexerNotFound
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/gherkin-2.12.0/lib/gherkin/i18n.rb:8
warning: already initialized constant LexerNotFound
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/gherkin-2.12.0/lib/gherkin/i18n.rb:8
warning: already initialized constant LexerNotFound
LoadError: no such file to load – gherkin
require at org/jruby/RubyKernel.java:1054
require at
/usr/local/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:36
native_impl at
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/gherkin-2.12.0/lib/gherkin/native/java.rb:25
I18n at
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/gherkin-2.12.0/lib/gherkin/i18n.rb:9
Gherkin at
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/gherkin-2.12.0/lib/gherkin/i18n.rb:6
(root) at
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/gherkin-2.12.0/lib/gherkin/i18n.rb:5
require at org/jruby/RubyKernel.java:1054
(root) at
/usr/local/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:1
require at
/usr/local/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:36
require at org/jruby/RubyKernel.java:1054
(root) at
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/gherkin-2.12.0/lib/gherkin/lexer/i18n_lexer.rb:2
(root) at
/usr/local/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:1
require at org/jruby/RubyKernel.java:1054
require at
/usr/local/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at
/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/gherkin-2.12.0/lib/gherkin.rb:1
require at org/jruby/RubyKernel.java:1054
(root) at
/usr/local/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:1
require at
/usr/local/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:60
load at org/jruby/RubyKernel.java:1073
(root) at /Users/mselv2/.rvm/gems/ruby-1.8.7-p371/bin/cucumber:19
mselv2m1:nikeplus-running-ios mselv2$

any thing should i do more to prevent this error ?

Thanks ,
Muthu S. SR

On Sat, Jun 29, 2013 at 12:03 AM, Joshua B. <

No , I did’t uninstall ruby 1.8.7 …

Please let me know what should i do now ? i did’t get you point in your
mail …

Christian MICHON >> beside the startup time
slower in jruby, you’ll not regret the full switch to jruby.

Thanks ,
Muthu S. SR

On Sat, Jun 29, 2013 at 1:06 PM, Christian MICHON <

Uninstall ruby-1.8.7?

I’m being serious here, not really joking: beside the startup time
slower in jruby, you’ll not regret the full switch to jruby.

On 6/29/13, Muthu S. SR [email protected] wrote:

/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/gherkin-2.12.0/lib/gherkin/i18n.rb:8

/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/gherkin-2.12.0/lib/gherkin/i18n.rb:6

   (root) at

/usr/local/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:60

you can always use: jruby -S cucumber features/java.feature

/Users/Shared/Development/NikeBuild/nikeplus-running-ios/features/step_definitions/first_call.rb:1

/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/gems/cucumber-1.3.2/bin/…/lib/cucumber/runtime/support_code.rb:82:in

/Users/mselv2/.rvm/gems/ruby-1.8.7-p371/bin/ruby_noexec_wrapper:14
mselv2m1:nikeplus-running-ios mselv2$

Thanks ,
Muthu S. SR


Christian

Thanks Hirostsugu , i have tried with your command …but this time its
different error as in below …

$ rvm use jruby
Using /Users/mselv2/.rvm/gems/jruby-1.7.4

*# Command *
mselv2m1:nikeplus-running-ios mselv2$ jruby -S cucumber
features/java.feature

Error :
Gem::LoadError: Could not find cucumber (>= 0) amongst []
to_specs at
/Users/mselv2/.rvm/rubies/jruby-1.7.4/lib/ruby/shared/rubygems/dependency.rb:247
to_spec at
/Users/mselv2/.rvm/rubies/jruby-1.7.4/lib/ruby/shared/rubygems/dependency.rb:256
gem at
/Users/mselv2/.rvm/rubies/jruby-1.7.4/lib/ruby/shared/rubygems.rb:1231
(root) at /usr/bin/cucumber:18

Please let me know is any thing required to install …?

Thanks ,
Muthu S. SR

Yes, now you need to actually install cucumber into jruby, since your
earlier copy of the gem was installed into MRI.

On Jun 29, 2013, at 7:29 PM, Muthu S. SR [email protected]
wrote:

No , I did’t uninstall ruby 1.8.7 …

Please let me know what should i do now ? i did’t get you point in your mail …

Since you’re using rvm, the fastest way to get it working is:

rvm install jruby-1.7.4 # if you haven’t done it already
rvm use jruby

You probably need to install the cucumber gem by running:

gem install cucumber

Muthu -

rvm will manage a separate set of gems for each Ruby you install, so
you’ll have to install any gems you need for JRuby. If ‘rvm jruby’ does
not work for you, I recommend creating aliases for easier use, such as:

rvm alias create jruby jruby-1.7.4

Then you can more easily switch to JRuby, with:

rvm jruby

With JRuby the current Ruby by doing the above, you then gem install
whatever you need, such as:

gem install cucumber

  • Keith

Keith R. Bennett

On Jun 29, 2013, at 11:21 PM, Muthu S. SR [email protected]
wrote:

Gem::LoadError: Could not find cucumber (>= 0) amongst []
to_specs at
/Users/mselv2/.rvm/rubies/jruby-1.7.4/lib/ruby/shared/rubygems/dependency.rb:247
to_spec at
/Users/mselv2/.rvm/rubies/jruby-1.7.4/lib/ruby/shared/rubygems/dependency.rb:256
gem at
/Users/mselv2/.rvm/rubies/jruby-1.7.4/lib/ruby/shared/rubygems.rb:1231
(root) at /usr/bin/cucumber:18

Please let me know is any thing required to install …?

Thanks ,
Muthu S. SR

You don’t have cucumber installed for jruby, then.

rvm use jruby
gem install cucumber

Note that rvm does not share gems across Ruby runtimes.

I suggest reading up on how RVM works. http://rvm.io/