Haml: Uninitialized constant error when upgrading to Ruby 2.5

Created on 11 Jan 2018  路  4Comments  路  Source: haml/haml

Hi folks,

We just upgraded to Ruby 2.5 and have started running into a number of cryptic error messages in our HAML views. Looks it might be related to parsing of attributes, but I'm not certain.

Here's the error:

NameError:
         uninitialized constant ActionView::CompiledTemplates::EXPR_ARG
         ./app/views/sessions/new.html.haml:22:in `block in _app_views_sessions_new_html_haml___2927548449020045079_69813386722600'

We're also seeing different but related errors in other views:

NameError:
         uninitialized constant ActionView::CompiledTemplates::EXPR_BEGEXPR_BEGEXPR_BEGEXPR_END
         ./app/views/signups/new.html.haml:48:in `block in _app_views_signups_new_html_haml___43708142755170209_69813350296920'

Any ideas?

Most helpful comment

Ruby 2.5 had breaking change in Ripper which is especially harmful for Haml 5. And the error seems to be the problem. It's fixed in Haml 5.0.4. https://github.com/haml/haml/blob/master/CHANGELOG.md#504

Please provide version information of Haml (not haml-rails, and ~> information is insufficient and please see Gemfile.lock) when you report issue, and reopen this if you find troubles with Haml 5.0.4.

All 4 comments

I mean, this seems to be something in ActionView that we were relying on.

Mind sharing what is on line 48 of ./app/views/signups/new.html.haml?

I have run into a similar issue after upgrading to Ruby 2.5.0

uninitialized constant ActionView::CompiledTemplates::EXPR_ARG on line app/views/bulkdeal/index.html.haml

%span{class: "action-#{bulkdeal.action.downcase}"}

I get this error for all dynamic attribute assignments like above.

Might be relevant:

gem 'rails', '~> 5.1.4'
gem 'pg', '~> 0.18'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'haml-rails', '~> 1.0'
gem 'jquery-rails', '~> 4.3', '>= 4.3.1'
gem 'uglifier', '>= 1.3.0'

Ruby 2.5 had breaking change in Ripper which is especially harmful for Haml 5. And the error seems to be the problem. It's fixed in Haml 5.0.4. https://github.com/haml/haml/blob/master/CHANGELOG.md#504

Please provide version information of Haml (not haml-rails, and ~> information is insufficient and please see Gemfile.lock) when you report issue, and reopen this if you find troubles with Haml 5.0.4.

I was also getting this on a basic meta tag:

%meta{name: 'viewport', content: 'width=device-width, initial-scale=1'}

The upgrade between haml 5.0.3 and 5.0.4 has the fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

atomAltera picture atomAltera  路  7Comments

Shamaoke picture Shamaoke  路  14Comments

ollym picture ollym  路  42Comments

dparis picture dparis  路  16Comments

ChristianPeters picture ChristianPeters  路  12Comments