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
IO.open 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 File.open(filemame, '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).
File.open(filemame, 'wb') do; end
I forgot to mention in the issue, but I was trying a Sinatra application with Rackup and Puma, that runs without problems in MRI.
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.
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.
Sure. Here it is: https://github.com/samflores/crash_app
Ah, great, will check it out! What should I do to run it?
Just run bundle install; bundle exec rackup -I.
bundle install; bundle exec rackup -I.
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.
f = File.read("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.
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 File.new and it would seem expected behavior that File.new would be implemented using a constructor. MRI probably also does that, but since it happens in C this isn't exposed to the developer.