无法使用jRuby安装rails

时间:2011-05-18 13:57:14

标签: ruby-on-rails ruby rubygems jruby

我正在尝试使用以下命令

使用jRuby安装rails
  

jruby -S gem install rails -v 3.0.6

但坚持错误:

JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
System.java:-2:in `arraycopy': java.lang.ArrayIndexOutOfBoundsException
        from DefaultResolver.java:111:in `makeTime'
        from DefaultResolver.java:277:in `create'
        from DefaultResolver.java:317:in `handleScalar'
        from DefaultResolver.java:435:in `orgHandler'
        from DefaultResolver.java:455:in `node_import'
        from org/yecht/ruby/DefaultResolver$s_method_1_0$RUBYINVOKER$node_import
.gen:65535:in `call'
        from CachingCallSite.java:146:in `call'
        from RubyLoadHandler.java:40:in `handle'
        from Parser.java:300:in `addNode'
        from DefaultYAMLParser.java:676:in `yyparse'
        from Parser.java:290:in `yechtparse'
        from Parser.java:284:in `parse'
        from YParser.java:152:in `load'
        from org/yecht/ruby/YParser$s_method_0_1$RUBYINVOKER$load.gen:65535:in `
call'
        from JavaMethod.java:630:in `call'
        from DynamicMethod.java:186:in `call'
        from CachingCallSite.java:309:in `cacheAndCall'
        from CachingCallSite.java:148:in `call'
        from CallOneArgNode.java:57:in `interpret'
        from LocalAsgnNode.java:123:in `interpret'
        from NewlineNode.java:104:in `interpret'
        from InterpretedMethod.java:180:in `call'
        from DefaultMethod.java:174:in `call'
        from CachingCallSite.java:309:in `cacheAndCall'
        from CachingCallSite.java:148:in `call'
        from CallOneArgNode.java:57:in `interpret'
        from LocalAsgnNode.java:123:in `interpret'
        from NewlineNode.java:104:in `interpret'
        from BlockNode.java:71:in `interpret'
        from InterpretedMethod.java:180:in `call'
        from DefaultMethod.java:174:in `call'
        from CachingCallSite.java:309:in `cacheAndCall'
        from CachingCallSite.java:148:in `call'
        from CallOneArgNode.java:57:in `interpret'

任何人都可以帮我解决这个错误。

提前致谢。

3 个答案:

答案 0 :(得分:6)

我刚才遇到过这个问题,但问题出在rspec。试试这个:
jruby --1.9 -S gem install rails -v 3.0.6

这告诉jruby使用ruby 1.9解释器。

答案 1 :(得分:4)

此错误已在JRuby 1.6.2中修复。

在命令行(Windows)上解决JRuby 1.6.1的问题:

set JRUBY_OPTS=--1.9
# in your specific case
gem install rails   

# this is where I got the error (Rails 3 with Bundler)
bundle update

答案 2 :(得分:0)

您正在安装的某些版本的gem可能会发生此错误,但不会发生其他版本。这是因为YAML错误是由YAML文件中的date字段引起的,如this comment for bug 5581中所述。

例如,生物宝石版本1.4.2对我造成例外。

如何获取元数据的说明来自Shaving a YAML Yak,除了我用gzcat代替gunzip和less

gem fetch bio --version 1.4.2
tar xvf bio-1.4.2.gem
gunzip metadata.gz
less metadata | grep date
date: 2011-08-26 00:00:00.000000000 Z

YAML.load("date: 2011-08-26 00:00:00.000000000 Z") # Causes exception

而对于生物的1.4.1版

gem fetch bio --version 1.4.1
tar xvf bio-1.4.1.gem
gunzip metadata.gz
less metadata | grep date
date: 2010-10-22 00:00:00 +09:00

YAML.load("date: 2010-10-22 00:00:00 +09:00") # Doesn't cause an exception

这样做sudo jruby -S gem install bio --version 1.4.1对我有用。

如果你想要最新的和最好的,那么你可以获取宝石并修改其元数据,或者自己构建宝石,但上面对我来说是Good Enough™。