Skip to content

Instantly share code, notes, and snippets.

@dnagir
Created December 7, 2011 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnagir/1441091 to your computer and use it in GitHub Desktop.
Save dnagir/1441091 to your computer and use it in GitHub Desktop.
No Stacktrace in JRuby
> rvm use jruby
Using /Users/dnagir/.rvm/gems/jruby-1.6.5
> bundle exec rspec spec/models/user_spec.rb --backtrace
NameError: uninitialized constant ActiveRecord
> rvm use 1.9.3
Using /Users/dnagir/.rvm/gems/ruby-1.9.3-p0
> bundle exec rspec spec/models/user_spec.rb --backtrace
/Users/dnagir/proj/abc/lib/extensions/has_address.rb:15:in `<top (required)>': uninitialized constant ActiveRecord (NameError)
from /Users/dnagir/proj/abc/config/initializers/extensions.rb:2:in `block in <top (required)>'
from /Users/dnagir/proj/abc/config/initializers/extensions.rb:1:in `each'
from /Users/dnagir/proj/abc/config/initializers/extensions.rb:1:in `<top (required)>'
from /Users/dnagir/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/engine.rb:556:in
@alg
Copy link

alg commented Dec 7, 2011

Try running your specs with rake with the --trace flag.

@dnagir
Copy link
Author

dnagir commented Dec 7, 2011

It won't help. It is not only spec-related. headius pointed out that it's an issue with JRuby http://jira.codehaus.org/browse/JRUBY-6252

@dnagir
Copy link
Author

dnagir commented Dec 7, 2011

Looks like it happens when process receives QUIT signal or similar. So it just doesn't have enough time to print the trace out (sounds strange, isn't It?).

@alg
Copy link

alg commented Dec 7, 2011

Not sure why wouldn't it help. Rake prints a stack trace upon exception in any ruby machine. "Not enough time" sounds ridiculous indeed.

@dnagir
Copy link
Author

dnagir commented Dec 7, 2011

--trace is similar to --backtrace in RSpec. But in any case, it indeed doesn't help.

Interesting thing is that it only seems to happen in the Rails initializers.

The exact answer was I think it's just a problem printing out backtraces when we're running the ^C exit hook..

Whatever the problem is I hope it will be fixed soon.

@dnagir
Copy link
Author

dnagir commented Dec 7, 2011

BTW, if you're keen to try it (which I doubt :-) ), here is my repro: https://gist.github.com/1441257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment