Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erubi superclass mismatch #946

Closed
dguettler opened this issue Aug 4, 2017 · 11 comments
Closed

Erubi superclass mismatch #946

dguettler opened this issue Aug 4, 2017 · 11 comments

Comments

@dguettler
Copy link

Error description

Attempting to run a Rails application with better_errors 2.3.0 which has a dependency to erubi (instead of erubis as in 2.2.0) results in the following error

.bundle/ruby/2.4.0/gems/haml-5.0.2/lib/haml/helpers/safe_erubi_template.rb:5: warning: toplevel constant Erubi referenced by ActionView::Template::Handlers::ERB::Erubi
rails aborted!
TypeError: superclass must be a Class (Module given)
.bundle/ruby/2.4.0/gems/haml-5.0.2/lib/haml/helpers/safe_erubi_template.rb:5:in `<module:Haml>'
.bundle/ruby/2.4.0/gems/haml-5.0.2/lib/haml/helpers/safe_erubi_template.rb:4:in `<top (required)>'
.bundle/ruby/2.4.0/gems/activesupport-5.0.5/lib/active_support/dependencies.rb:293:in `require'
.bundle/ruby/2.4.0/gems/activesupport-5.0.5/lib/active_support/dependencies.rb:293:in `block in require'

Configuration

  • rails 5.0.5
  • haml 5.0.2
  • haml-rails 1.0.0
  • better_errors 2.3.0
@martinstreicher
Copy link

martinstreicher commented Aug 7, 2017

I get this error in Rails 4 as well.

  • haml 5.0.2
  • better_errors 2.3.0
  • hame-rails 1.0.0
  • rails 4.2.8

Removing better_errors avoid the problem.

@RobinDaugherty
Copy link
Contributor

RobinDaugherty commented Aug 8, 2017

better_errors 2.3.0 adds a dependency on erubi. This can be reproduced by adding erubi to the Gemfile, regardless of whether better_errors is in the Gemfile.

Once Erubis has been added to the bundle, haml chooses Erubi. In rails 5.0.5, the exception occurs on the class declaration line of lib/haml/helpers/safe_erubi_template.rb:

module Haml
  class ErubiTemplateHandler < ActionView::Template::Handlers::ERB::Erubi

ActionView::Template::Handlers::ERB::Erubi is a very mysterious object, but it seems to be a pure reference to the Erubi module, which also explains the warning:

> Where.is(ActionView::Template::Handlers::ERB::Erubi)
(pry):1: warning: toplevel constant Erubi referenced by ActionView::Template::Handlers::ERB::Erubi
=> ["/usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/erubi-1.6.1/lib/erubi.rb", 24]

I can find no direct declaration of ActionView::Template::Handlers::ERB::Erubi in actionview, erubi, haml, or haml-rails. But according to that, it is a copy of Erubi and has no other methods.

@RobinDaugherty
Copy link
Contributor

I've narrowed it down a bit: any constant referenced under ActionView::Template's namespace causes a reference to that constant in the root namespace:

> ActionView::Template::Erubi
(eval):1: warning: toplevel constant Erubi referenced by ActionView::Template::Erubi
> ActionView::Template::ActionView
(eval):1: warning: toplevel constant ActionView referenced by ActionView::Template::ActionView
> defined? ActionView::Template::Handlers::ERB::Erubi
=> "expression"
> defined? ActionView::Template::Handlers::ERB::sdfsdf
=> nil
> defined? ActionView::Template::Handlers::ERB::ActionView
=> "constant"

@RobinDaugherty
Copy link
Contributor

I've opened #948 to fix this.

@dguettler
Copy link
Author

dguettler commented Aug 8, 2017 via email

@thomasbalsloev
Copy link

thomasbalsloev commented Aug 10, 2017

I had this problem also and fixed gem Better Errors to 2.2.0.
But today my app broke again with the same error.
This time the cause is i18n-tasks 0.9.17! Fixing this to 0.9.16 is a workaround.

Hope this helps somebody.

@Tosh39
Copy link

Tosh39 commented Aug 14, 2017

Seems to work fine with Better Errors 2.2.0. Thanks!

@k0kubun
Copy link
Member

k0kubun commented Aug 17, 2017

I want people in this issue to test latest master branch of Haml including #948. Thanks!

@k0kubun
Copy link
Member

k0kubun commented Aug 18, 2017

Sorry for early merge, but could you guys try master including #952?

@dguettler
Copy link
Author

dguettler commented Aug 18, 2017 via email

@mmyoji
Copy link

mmyoji commented Aug 22, 2017

Works fine for my project as well. Thanks!

  • Ruby v2.4.1
  • Rails v5.0.5
  • haml-rails v1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants