节俭宝石和JRuby

问题描述:

我最近在MRI中使用JRuby和Thrift gem后才安装它。我遇到了一个问题,如果我需要节俭,我会收到消息无法加载thrift_native扩展,默认为纯Ruby库。如果我然后尝试并要求在ruby中生成的代码thrift,我会得到这个错误:NameError:未初始化的常量Thrift :: Struct_Union

I just recently installed JRuby and the Thrift gem after using it in MRI. I'm running into a problem where if I require 'thrift' I get the message "Unable to load thrift_native extension. Defaulting to pure Ruby libraries." If I then try and require the code thrift generated in ruby I'll get this error: "NameError: uninitialized constant Thrift::Struct_Union"

现在的节俭宝石不是与JRuby合作?

Is the thrift gem currently not working with JRuby?

有没有什么方法可以使用JRuby除了使用gem之外的节俭?

Is there something I can do to use thrift with JRuby besides using the gem?

编辑:在我的Mac上挖掘周围后,我发现MRI宝石和JRuby宝石是不同的,即使宝石是相同的版本(0.2.0.4)。现在这似乎是一个可怕的想法,但是如果您将MRI宝石中的.rb文件复制到JRuby gem并将 require'thrift / struct_union'添加到thrift.rb中将不再获得与Thrift gem相关的任何错误,除非它找不到thirft_native并且将使用纯Ruby库。这可以解释,因为thrift_native是为C而不是Java。

After digging around on my mac, I found that the MRI gem and JRuby gem are different even though the gems are the same version (0.2.0.4). Now this seems like a terrible idea, but if you copy the .rb files from the MRI gem into the JRuby gem and add require 'thrift/struct_union' to thrift.rb you will no longer get any errors related to the Thrift gem except that it can't find thirft_native and will use pure Ruby libraries. This can be explained since thrift_native is made for C not Java.

当您使用JRuby时,我会使用Java本地节俭客户端。对我来说,节俭是首先转向JRuby的原因,因为Ruby实现相当慢并且很麻烦。

When you're already using JRuby, I would use a Java native thrift client. For me, thrift was the reason for moving to JRuby in the first place, since the Ruby implementation is rather slow and buggy.