2011-10-05 29 views
1

我遇到了使用Capistrano的错误。我已经缩小的错误逐字这行代码:Ruby中的封送字符串

puts message 

当“消息”是,有来自通过网络-SSH一个删除服务器的字符串。

所以我试图创建一个重现此错误的单个.rb文件。应该很容易......我只是Marshal.dump(message),将它给我的东西复制/粘贴到脚本中的Marshal.load(...)中。

但是当我这样做,我的单个.rb文件完美地工作。

所以我检查了我的应用程序,当我执政时,立即解开capistrano中的字符串,它的工作原理。因此,编组中的一些东西正在迷失,并且阻止我可靠地复制错误。

我使用JRuby:

jruby 1.6.4 (ruby-1.9.2-p136) (2011-08-23 17ea768) (Java HotSpot(TM) Client VM 1.6.0_26) [Windows 7-x86-java] 

上放

ByteBuffer.java:352:in `wrap': java.lang.IndexOutOfBoundsException 
     from ChannelDescriptor.java:618:in `write' 
     from RubyIO.java:1386:in `fwrite' 
     from RubyIO.java:1319:in `write' 
     from RubyIO$i$1$0$write.gen:65535:in `call' 
     from RubyClass.java:686:in `finvoke' 
     from RuntimeHelpers.java:548:in `invoke' 
     from RubyBasicObject.java:358:in `callMethod' 
     from RubyIO.java:2297:in `write' 
     from RubyIO.java:2283:in `putsArray' 
     from RubyIO.java:2252:in `puts' 
     from RubyKernel.java:522:in `puts' 
     from RubyKernel$s$0$0$puts.gen:65535:in `call' 
     from JavaMethod.java:630:in `call' 
     from DynamicMethod.java:207:in `call' 
     from CachingCallSite.java:167:in `call' 
     from FCallOneArgNode.java:36:in `interpret' 
     from NewlineNode.java:104:in `interpret' 
     from IfNode.java:117:in `interpret' 
     from NewlineNode.java:104:in `interpret' 
     from ASTInterpreter.java:112:in `INTERPRET_BLOCK' 
     from Interpreted19Block.java:203:in `evalBlockBody' 
     from Interpreted19Block.java:154:in `yield' 
     from Block.java:130:in `yield' 
     from RubyString.java:6830:in `each_lineCommon19' 
     from RubyString.java:6801:in `each_lineCommon19' 
     from RubyString.java:6790:in `lines' 
     from RubyString$i$lines.gen:65535:in `call' 
     from JavaMethod.java:442:in `call' 
     from RubyClass.java:544:in `finvoke' 
     from RuntimeHelpers.java:541:in `invoke' 
     from RubyBasicObject.java:382:in `callMethod' 
     from RubyEnumerator.java:190:in `each' 
     from RubyEnumerator$i$0$0$each.gen:65535:in `call' 
     from CachingCallSite.java:142:in `callBlock' 
     from CachingCallSite.java:153:in `callIter' 
     from CallNoArgBlockNode.java:64:in `interpret' 
     from NewlineNode.java:104:in `interpret' 
     from BlockNode.java:71:in `interpret' 
     from IfNode.java:117:in `interpret' 
     from NewlineNode.java:104:in `interpret' 
     from BlockNode.java:71:in `interpret' 
     from ASTInterpreter.java:75:in `INTERPRET_METHOD' 
     from InterpretedMethod.java:276:in `call' 
     from DefaultMethod.java:211:in `call' 
     from CachingCallSite.java:235:in `call' 
     from FCallThreeArgNode.java:40:in `interpret' 
     from NewlineNode.java:104:in `interpret' 
     from ASTInterpreter.java:75:in `INTERPRET_METHOD' 
     from InterpretedMethod.java:255:in `call' 
     from DefaultMethod.java:203:in `call' 
     from RubyClass.java:582:in `finvoke' 
     from RubyBasicObject.java:1697:in `send19' 
     from RubyKernel.java:2121:in `send19' 
     from RubyKernel$s$send19.gen:65535:in `call' 
     from JavaMethod.java:300:in `call' 
     from CachingCallSite.java:235:in `call' 
     from CallThreeArgNode.java:61:in `interpret' 
     from NewlineNode.java:104:in `interpret' 
     from BlockNode.java:71:in `interpret' 
     from ASTInterpreter.java:112:in `INTERPRET_BLOCK' 
     from Interpreted19Block.java:203:in `evalBlockBody' 
     from Interpreted19Block.java:191:in `yield' 
     from Interpreted19Block.java:122:in `call' 
     from Block.java:89:in `call' 
     from RubyProc.java:274:in `call' 
     from RubyProc.java:262:in `call19' 
     from RubyProc$i$0$0$call19.gen:65535:in `call' 
     from DynamicMethod.java:227:in `call' 
     from DynamicMethod.java:223:in `call' 
     from CachingCallSite.java:235:in `call' 
     from CallThreeArgNode.java:61:in `interpret' 
     from NewlineNode.java:104:in `interpret' 
     from BlockNode.java:71:in `interpret' 
     from ASTInterpreter.java:112:in `INTERPRET_BLOCK' 
     from Interpreted19Block.java:203:in `evalBlockBody' 
     from Interpreted19Block.java:191:in `yield' 
     from Interpreted19Block.java:122:in `call' 
     from Block.java:89:in `call' 
     from RubyProc.java:274:in `call' 
     from RubyProc.java:262:in `call19' 
     from RubyProc$i$0$0$call19.gen:65535:in `call' 
     from DynamicMethod.java:219:in `call' 
     from DynamicMethod.java:215:in `call' 
     from CachingCallSite.java:201:in `call' 
     from CallTwoArgNode.java:59:in `interpret' 
     from IfNode.java:117:in `interpret' 
     from NewlineNode.java:104:in `interpret' 
     from BlockNode.java:71:in `interpret' 
     from ASTInterpreter.java:75:in `INTERPRET_METHOD' 
     from InterpretedMethod.java:190:in `call' 
     from DefaultMethod.java:179:in `call' 
     from CachingCallSite.java:312:in `cacheAndCall' 
     from CachingCallSite.java:169:in `call' 
     from CallOneArgNode.java:57:in `interpret' 
     from NewlineNode.java:104:in `interpret' 
     from BlockNode.java:71:in `interpret' 
     from ASTInterpreter.java:75:in `INTERPRET_METHOD' 
     from InterpretedMethod.java:212:in `call' 
     from DefaultMethod.java:187:in `call' 
     from RubyClass.java:563:in `finvoke' 
     from RubyBasicObject.java:1691:in `send19' 
     from RubyKernel.java:2117:in `send19' 
     from RubyKernel$s$send19.gen:65535:in `call' 
     from JavaMethod.java:283:in `call' 

这正好为比但它只是一堆动态方法调用的较长的错误。

错误还介绍了关于puts "#{message}"puts "#{message.strip}"不同的错误

回答

0

这是JRuby 1.6.4中的一个错误。它已在1_6分支中修复,应该在1.6.5版本中修复。

你可以阅读更多关于它在这里:

https://jira.codehaus.org/browse/JRUBY-6116

长话短说:如果你要留在1.6.4

编辑使用str = Marshal.load(Marshal.dump(str)):1.6.5已经发布,包含此修复程序。

0

这可能是该消息是另一种Ruby对象中的类http://www.ruby-doc.org/core/IO.html红宝石IO家庭赋予的,而不是一个字符串,但某种缓冲自带来自ssh会话。尝试Marshal.dump(message.to_s),或者将message.class确认它实际是什么。

+0

我确认它是类String。 – Lelon

+0

英联邦英语发音者应该注意,它是'Marshal',而不是'Marshall',因为Ruby(和日语程序员)使用美式英语。 –