Rubinius File#initialize not working on 1.9 mode #2172

samflores opened this Issue Feb 23, 2013 · 10 comments

3 participants

ERROR: the VM is exiting improperly running /Users/samflores/.gem/rbx/1.9.3/bin/rackup
intended operation: :exception
associated value: nil
destination scope: unknown
An exception occurred
    method 'initialize': given 3, expected 1 (ArgumentError)

                    File#initialize at kernel/common/file19.rb:55
                          Class#new at kernel/alpha.rb:96
                   at kernel/common/io.rb:212
  Rubinius::Loader#write_last_error at kernel/loader.rb:787
              Rubinius::Loader#main at kernel/loader.rb:844

I'm using Rubinius HEAD.


Paying a little more attention to that short backtrace and reading the mentioned code I see the issue occurred while trying to write other exception to the rubinius_last_error file. Running, 'wb') do; end within irb raises no exception, but I didn't figure out what the real exception was (the one Rubinius is trying to write).

I forgot to mention in the issue, but I was trying a Sinatra application with Rackup and Puma, that runs without problems in MRI.

Rubinius member

Could you give us the exact instructions for how to reproduce this? The easier we can replicate the problem, the easier it is to fix :).


I've been trying to determine which instruction caused the issue.

It's an application with considerable amount of code and since the real exception wasn't being displayed in the backtrace it was a detective job, but I finally figured out my mistake.

I guess it's not a good idea to have a DataMapper model called File ;) Don't know why MRI didn't whine about that.

Sorry for bothering you with this report. Feel free to close the issue and keep the great job.

Rubinius member

well, if there's a different in MRI constant lookup and Rubinius that's probably a bug. Do you think you could provide a way for us so we can reproduce the issue? Perhaps an extracted version / simplified? Rather not leave a potential bug lingering around if it's an actual issue.

Rubinius member

Ah, great, will check it out! What should I do to run it?


Just run bundle install; bundle exec rackup -I.

Rubinius member

Ok, thanks :). It's just that even getting it to run sometimes can be frustrating if you dive into an unknown code base. Often people don't realize the exact steps etc. I probably would have banged my head on the rackup command for at least some time.

Rubinius member

Smaller repro:

./bin/rbx -X19

class File
  def initialize(arg1)

f ="Gemfile")

Rubinius calls the Ruby definition of initialize whereas MRI calls the C method (which isn't overridden afaik).
So you get away with writing broken code like this in MRI but you don't on Rubinius.
Using a top level constant File to define a DM model is not a good idea (because class File deals with files and you shouldn't use that to deal with anything else).
It could be namespaced in a module for example.

This issue is similar to #2077, I guess people expect this code to work on Rubinius too.

Rubinius member

I'm closing this issue, since defining your own File class and overwriting methods like initialize isn't something we'd like to support and I consider doing that a bug in itself :). I consider this issue different from the Array one, since there the discussion was about adding new methods that already existed on MRI and mirrors can help with that.

Also the signature for File#initialize is the same as and it would seem expected behavior that would be implemented using a constructor. MRI probably also does that, but since it happens in C this isn't exposed to the developer.

@dbussink dbussink closed this Mar 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment