Skip to content


JRuby issue with version 2.6.0 #61

rohitn opened this Issue · 12 comments

8 participants



This commit 5917c90 which is merged in 2.6.0 causes net-ssh to break when using key authentication in JRuby (, 1.7.0.preview2 in 1.8 and 1.9 mode). I spent a couple of hours trying to figure out why it was failing but was unable to.

Stack trace:

FATAL 2012-09-20 08:05:19 5900 [Vulcan::Tracking]: <ArgumentError> wrong number of arguments (2 for 1)
        /home/offers/tracking/shared/bundle/jruby/1.8/gems/net-ssh-2.6.0/lib/net/ssh/key_factory.rb:77:in `load_data_private_key'
        /home/offers/tracking/shared/bundle/jruby/1.8/gems/net-ssh-2.6.0/lib/net/ssh/key_factory.rb:42:in `load_private_key'
        /home/offers/tracking/shared/bundle/jruby/1.8/gems/net-ssh-2.6.0/lib/net/ssh/authentication/key_manager.rb:214:in `load_identities'
        org/jruby/ `collect'
        /home/offers/tracking/shared/bundle/jruby/1.8/gems/net-ssh-2.6.0/lib/net/ssh/authentication/key_manager.rb:207:in `load_identities'
        /home/offers/tracking/shared/bundle/jruby/1.8/gems/net-ssh-2.6.0/lib/net/ssh/authentication/key_manager.rb:100:in `each_identity'
        /home/offers/tracking/shared/bundle/jruby/1.8/gems/net-ssh-2.6.0/lib/net/ssh/authentication/methods/publickey.rb:19:in `authenticate'
        /home/offers/tracking/shared/bundle/jruby/1.8/gems/net-ssh-2.6.0/lib/net/ssh/authentication/session.rb:78:in `authenticate'
        org/jruby/ `each'
        /home/offers/tracking/shared/bundle/jruby/1.8/gems/net-ssh-2.6.0/lib/net/ssh/authentication/session.rb:65:in `authenticate'
        /home/offers/tracking/shared/bundle/jruby/1.8/gems/net-ssh-2.6.0/lib/net/ssh.rb:190:in `start'
        /home/offers/tracking/shared/bundle/jruby/1.8/gems/net-sftp-2.0.5/lib/net/sftp.rb:31:in `start'

Thanks for the report. I'll see if I can get some help on it.


Same for jruby-1.6.8


I too have encountered this but it is not consistently. It seems to error on RHEL 6.3 but not CentOS 6.2 or Mountain Lion. On RHEL it errors across openjdk 1.6.0 and 1.7.0 and jruby - 1.7.0.RC1 from the limited tests that I have run. Are the two other reporters running on RHEL ?


I'm running RHEL 6.1 and also see this error occur. It's inconsistent. Happens repeatedly in one shell but then sometimes when launching another it goes away. Not sure why. Goes away when I switch back to 2.5.2.


Ubuntu 10.04.4 LTS
jruby (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_26) [linux-amd64-java]


LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 6.1 (Santiago)
Release: 6.1
Codename: Santiago

jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_33) [linux-amd64-java]


Following up a bit, I read somewhere that only accepts one argument in jruby-openssl (i.e. jruby-ossl), but accepts two in MRI, and this code is calling it with two. I went and tried to look through jruby-ossl, and realized that what I don't know about the connection between ruby and Java module definitions for ruby could fill a warehouse. And it seems to me that the method actually does accept 2 parameters, but the error message indicates only one is accepted. But this seems like the right place to start (assuming this is actually the code getting called):

public static class PKeyModule {

    @JRubyMethod(name = "read", meta = true, optional = 1)
    public static IRubyObject read(ThreadContext ctx, IRubyObject recv, IRubyObject[] args) {
        Ruby runtime = ctx.runtime;
        IRubyObject data;
        char[] pass;
        int argc = Arity.checkArgumentCount(runtime, args, 1, 2);
        switch (argc) {
        case 1:
            data = args[0];
            pass = null;
            data = args[0];
            pass = args[1].isNil() ? null : args[1].toString().toCharArray();

I'm not savvy enough with this code to know what's what, but hopefully this helps? For now I'm sticking with 2.5.2


It's a typo in that JRubyMethod annotation. jruby-openssl has been merged into the JRuby codebase for JRuby 1.7, and the fix is on master here: jruby/jruby@d516385. For JRuby 1.6, you can downgrade jruby-openssl to version 0.7.4 (before they added the method) and it should work.


Thanks guys. I updated the readme with the fix for 1.6 (downgrade jruby-openssl).

@delano delano closed this

I just found out it breaks again with jruby 1.7.2. It worked just fine with 1.7.0


Same error? Can you post a stack trace.


Well, its exactly the same stack trace (the issue was opened with). Line 77 of key_factory.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.