从analyze.rb运行Univa Grid Engine Open Core脚本时,出现TypeError:
$ ./analyze.rb
./analyze.rb:214:in `<main>': superclass mismatch for class Queue (TypeError)
该脚本是为Ruby 1.8.1开发的,但我使用的是更新版本:
$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
$ uname -a
Linux <hostname> 2.6.32-642.4.2.el6.x86_64 #1 SMP Mon Aug 15 02:06:41 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
$ head -n1 /etc/issue
Red Hat Enterprise Linux Server release 6.8 (Santiago)
我已经打开了a GitHub issue,但是repro上的最后一次活动是从6年前开始的,所以这也是我在这里问的原因。
修改
如果我将我的Ruby版本降级为1.9.3
,则TypeError
消失...
$ conda uninstall ruby
Fetching package metadata .......
Solving package specifications: ..........
Package plan for package removal in environment /tools/general/app/anaconda-python-3.4/envs/accounting:
The following packages will be REMOVED:
ruby: 2.2.3-0 bioconda
Proceed ([y]/n)? y
Unlinking packages ...
[ COMPLETE ]|###############################################################################################################| 100%
$ conda install -c kalefranz ruby=1.9
Fetching package metadata .........
Solving package specifications: ..........
Package plan for installation in environment /tools/general/app/anaconda-python-3.4/envs/accounting:
The following packages will be downloaded:
package | build
---------------------------|-----------------
libffi-3.2.1 | 1 38 KB
ncurses-5.9 | 5 640 KB kalefranz
ruby-1.9.3.551 | 0 12.8 MB kalefranz
------------------------------------------------------------
Total: 13.4 MB
The following NEW packages will be INSTALLED:
libffi: 3.2.1-1
ncurses: 5.9-5 kalefranz
ruby: 1.9.3.551-0 kalefranz
Proceed ([y]/n)? y
Fetching packages ...
libffi-3.2.1-1 100% |############################################################################################| Time: 0:00:00 852.02 kB/s
ncurses-5.9-5. 100% |############################################################################################| Time: 0:00:01 504.77 kB/s
ruby-1.9.3.551 100% |############################################################################################| Time: 0:00:22 606.26 kB/s
Extracting packages ...
[ COMPLETE ]|###############################################################################################################| 100%
Linking packages ...
[ COMPLETE ]|###############################################################################################################| 100%
$ ruby -v
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
$ ruby ./analyze.rb
usage: analyze.rb <options> accounting_file
-help
-r records table
-u users table
-h hosts table
-par parallel environment table
-q queues table
-p projects table
-c categories table
-ts timesteps table
-ts_c categories per timestep
-ts_j jobs per timestep
-t "first"|<first> "last"|<last> full analysis, but print these timesteps only
...但是当我尝试处理会计文件时,会弹出其他错误:
$ ./analyze.rb -ts /gridware/uge/default//common/accounting
invalid record 14473350 submitted 1503752102682 started 0 ended 0 wallclock 0
invalid record 14473350 submitted 1503752102682 started 0 ended 0 wallclock 0
invalid record 14473350 submitted 1503752102682 started 0 ended 0 wallclock 0
invalid record 14473350 submitted 1503752102682 started 0 ended 0 wallclock 0
invalid record 14473350 submitted 1503752102682 started 0 ended 0 wallclock 0
./analyze.rb:151:in `split': invalid byte sequence in UTF-8 (ArgumentError)
from ./analyze.rb:151:in `block in initialize'
from ./analyze.rb:149:in `each_line'
from ./analyze.rb:149:in `initialize'
from ./analyze.rb:557:in `new'
from ./analyze.rb:557:in `read_records'
from ./analyze.rb:774:in `<main>'
答案 0 :(得分:2)
该脚本添加了一个类Queue
,如下所示:
class Queue < Debitable
end
Ruby 2.1引入了自己的Queue
类,它继承自Object
。这会导致你提到的错误。
以下脚本演示了问题:
class Thing < Object
end
class Thing < String
end
如果你运行它,那么Ruby会告诉你它有一个superclass mismatch for class Thing (TypeError)
解决这个问题的两种方法:
Queue
类不存在(这有点令人伤心,不推荐)Queue
的所有出现替换为MyQueue
(您可以自由地提出更好的名称)可能一个6岁的剧本也包含其他问题......祝你好运。
另外:如果你真的需要不同的ruby版本,你可以查看像RVM或RBEnv这样的ruby版本管理器。