Search code examples
rubysungridengine

superclass mismatch for class Queue (TypeError)


When running the analyze.rb script from Univa Grid Engine Open Core , I get a TypeError:

$ ./analyze.rb 
./analyze.rb:214:in `<main>': superclass mismatch for class Queue (TypeError)

The script was developed for Ruby 1.8.1, but I am using a more recent version:

$ 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)

I've opened a GitHub issue, but the last activity on the repro was from 6 years ago, so that's why I am also asking here.

Edit:

If I downgrade my Ruby version to 1.9.3, the TypeError dissapears...

$ 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

...but as soon as I try to process the accounting file, other errors pop up:

$ ./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>'

Solution

  • The script adds a class Queue like this:

    class Queue < Debitable 
    end
    

    Ruby 2.1 introduced its own Queue class which inherits from Object. This leads to the error you mention.

    Following script demonstrates the problem:

    class Thing < Object
    end
    
    class Thing < String
    end
    

    If you run it then Ruby will tell you that it has a superclass mismatch for class Thing (TypeError)

    Two ways to solve this:

    • Use Ruby < 2.1 so the Queue class does not exist (which is kind of sad and not recommended)
    • update the script, replace all occurences of Queue with MyQueue (you are free to come up with a better name)

    Potentially a 6 year old script contains other problems as well... so good luck.

    Also: if you really need different ruby version you can look at a ruby version manager like RVM or RBEnv.