Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jruby 1.7.20 and ruby 1.9 mode. #2912

Closed
ayappanec opened this issue May 6, 2015 · 9 comments
Closed

Jruby 1.7.20 and ruby 1.9 mode. #2912

ayappanec opened this issue May 6, 2015 · 9 comments
Milestone

Comments

@ayappanec
Copy link

Hbase shell makes use of Jruby 1.6.8 which works in ruby 1.8 mode. If jruby is updated to 1.7.20 version, hbase shell and its related testcases fails since the newer version works in ruby 1.9 mode. Is there a way to set the jruby-complete.17.20 jar file in ruby 1.8 mode?

@mkristian
Copy link
Member

yes, jruby-1.7.x defaults to 1.9

via commandline you can use the switch '--1.8'

or use a .jrubyrc file: see jruby -jar jruby-complete-1.7.20.jar --properties which dumps a sample .jrubyrc file - look for compat.version

or use -Djruby.compat.version=1.8 or set this system properties on the java
side before you "execute" jruby

@ayappanec
Copy link
Author

I didn't get that properly.
Suppose say we have an already built jruby-complete.17.20.jar file in .m2 repository. And we build & package Apache Hbase which takes this jruby-complete jar and adds it to its classpath. How can we make the entire jar to work in ruby 1.8 mode?

@mkristian
Copy link
Member

mkristian commented May 6, 2015 via email

@ayappanec
Copy link
Author

For Hbase shell. it has the below script

if [ "$COMMAND" = "shell" ] ; then
  # eg export JRUBY_HOME=/usr/local/share/jruby
  if [ "$JRUBY_HOME" != "" ] ; then
    CLASSPATH="$JRUBY_HOME/lib/jruby.jar:$CLASSPATH"
    HBASE_OPTS="$HBASE_OPTS -Djruby.home=$JRUBY_HOME -Djruby.lib=$JRUBY_HOME/lib"
  fi
        #find the hbase ruby sources
  if [ -d "$HBASE_HOME/lib/ruby" ]; then
    HBASE_OPTS="$HBASE_OPTS -Dhbase.ruby.sources=$HBASE_HOME/lib/ruby"
  else
    HBASE_OPTS="$HBASE_OPTS -Dhbase.ruby.sources=$HBASE_HOME/hbase-shell/src/main/ruby"
  fi
  HBASE_OPTS="$HBASE_OPTS $HBASE_SHELL_OPTS"
  CLASS="org.jruby.Main -X+O ${JRUBY_OPTS} ${HBASE_HOME}/bin/hirb.rb"

For the hbase (maven) testcase "TestShell"
we have this error,
Running org.apache.hadoop.hbase.client.TestShell
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 16.006 sec <<< FAILURE! - in org.apache.hadoop.hbase.client.TestShell
testRunShellTests(org.apache.hadoop.hbase.client.TestShell) Time elapsed: 1.359 sec <<< ERROR!
org.jruby.embed.EvalFailedException: (LoadError) no such file to load -- src/test/ruby/hbase/hbase_test.rb
at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:132)
at org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1341)
at org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1386)
at org.apache.hadoop.hbase.client.TestShell.testRunShellTests(TestShell.java:81)
Caused by: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- src/test/ruby/hbase/hbase_test.rb
at org.jruby.RubyKernel.load(org/jruby/RubyKernel.java:1091)
at RUBY.(root)(src/test/ruby/tests_runner.rb:50)
at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1613)
at RUBY.(root)(src/test/ruby/tests_runner.rb:48)

@mkristian
Copy link
Member

replace this line from your script
CLASS="org.jruby.Main -X+O ${JRUBY_OPTS} ${HBASE_HOME}/bin/hirb.rb"
with (to force 1.8 mode)
CLASS="org.jruby.Main --1.8 -X+O ${JRUBY_OPTS} ${HBASE_HOME}/bin/hirb.rb"
or (adding "." to LOAD_PATH)
CLASS="org.jruby.Main -I. -X+O ${JRUBY_OPTS} ${HBASE_HOME}/bin/hirb.rb"

since from the error it looks like the 1.9 feature not to find files on current working directory unless this directory is on the LOAD_PATH

@ayappanec
Copy link
Author

I think i didn't convey clearly about the hbase shell problem and hbase testcase issue. Both got mixed up here. But the root cause is same (Jruby is used in 1.9 mode)

1) Shell problem

The script loads the hbase shell when invoked.
I modified the script to
CLASS="org.jruby.Main --1.8 -X+O ${JRUBY_OPTS} ${HBASE_HOME}/bin/hirb.rb"
but still when invoked it throws out

[ayappan@soe07-vm3 bin]$ ./hbase shell
include_class is deprecated. Use java_import.
include_class is deprecated. Use java_import.
include_class is deprecated. Use java_import.
NoMethodError: undefined method `getTerminal' for Java::Jline::Terminal:Module
refresh_width at /home/ayappan/hbase/bin/../hbase-shell/src/main/ruby/shell/formatter.rb:33
initialize at /home/ayappan/hbase/bin/../hbase-shell/src/main/ruby/shell/formatter.rb:46
(root) at /home/ayappan/hbase/bin/../bin/hirb.rb:128

contents of /home/ayappan/hbase/bin/../hbase-shell/src/main/ruby/shell/formatter.rb
def refresh_width()
if $stdout.tty?
@max_width = Java::jline.Terminal.getTerminal().getTerminalWidth() ----->33
else
@max_width = 0
end
end

2)Testcase issue

Hbase has this testcase code.

package org.apache.hadoop.hbase.client;

import java.io.IOException;

import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.jruby.embed.PathType;
import org.junit.Test;
import org.junit.experimental.categories.Category;

@category({ ClientTests.class, LargeTests.class })
public class TestShell extends AbstractTestShell {

@test
public void testRunShellTests() throws IOException {
System.setProperty("shell.test.exclude", "replication_admin_test.rb");
// Start all ruby tests
jruby.runScriptlet(PathType.ABSOLUTE, "src/test/ruby/tests_runner.rb");
}

}

@headius
Copy link
Member

headius commented May 8, 2015

Your 1) issue above doesn't look like a 1.8/1.9 problem. It's failing to find a method in jline's Terminal class. This method does not exist on the Terminal in the jline that JRuby 1.7.20 ships, at least. I guess you are attempting to update hbase? You will need to figure out an alternative to this call.

The 2) issue could be a 1.8/1.9 issue if the file in question is in CWD. Normally 1.9 mode will not look in CWD unless it is explicitly added to the load path, using -I. as @mkristian suggested above. You can also force JRuby to use 1.8 mode throughout a given JVM by setting property jruby.compat.version to 1.8.

I'm not seeing a JRuby issue yet :-)

@headius
Copy link
Member

headius commented May 8, 2015

Oh, I would also suggest that the hbase update just use 1.9 mode and deal with the (mostly minor) issues that will result. 1.8 mode is completely gone in JRuby 9000, and 1.8.7 has been EOL in the Ruby world for years.

@kares kares added this to the Won't Fix milestone Mar 1, 2018
@kares
Copy link
Member

kares commented Mar 1, 2018

closing since its a JRuby 1.7.x (EOL) report against its (non preferred) --1.8 mode

@kares kares closed this as completed Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants