middleman / middleman

Hand-crafted frontend development

Home Page:https://middlemanapp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"uninitialized constant Haml::Options" error while launching Middleman server on a fresh install

teemutammela opened this issue · comments

I tried creating a fresh new Middleman project and launching the server.

$ gem install middleman
$ mkdir project
$ middleman init
$ middleman server

Command middleman server fails to launch giving the following error message:

/Users/username/.rvm/gems/ruby-3.1.2/gems/middleman-core-4.4.2/lib/middleman-core/renderers/haml.rb:49:in `initialize': uninitialized constant Haml::Options (NameError)

::Haml::Options.defaults[:context] = nil

I'm also getting the same error message this way.

$ gem install middleman
$ middleman init project

Additional information

  • Ruby version: 3.1.2 installed via RVM
  • Middleman version: 4.2.2
  • OS version: macOS 12.5

As a temporary workaround you can fix this in any project using a Gemfile by limiting the version of haml in your Gemfile, for example:

source "https://rubygems.org"

gem 'middleman', '~> 4.2'
gem 'middleman-autoprefixer'

# Temporary fix for https://github.com/middleman/middleman/issues/2569
gem 'haml', '~> 5.0'

Thanks, that temporary solution fixed the problem for now. Any ETA for a permanent fix?

I'm seeing the same problem. I can lock the haml gem inside an existing project's Gemfile, however that doesn't solve the issue that middleman init installs haml 6.0, and then errors with the error described in the issue title and description.

After the middleman init fails, I remove haml 6.0 with gem uninstall, then the init works. However, during the creation of the new site, it installs haml 6.0 again. I could then lock the new project's haml inside the Gemfile, but it seems like init is installing haml 6.0.

Same problem for me. Brand new project with middleman init Result is:

/Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/renderers/haml.rb:49:in `initialize': uninitialized constant Haml::Options (NameError)

        ::Haml::Options.defaults[:context] = nil
              ^^^^^^^^^
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extension_manager.rb:66:in `new'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extension_manager.rb:66:in `activate'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extensions.rb:120:in `block in auto_activate'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/3.1.0/set.rb:511:in `each_key'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/3.1.0/set.rb:511:in `each'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extensions.rb:117:in `auto_activate'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extension_manager.rb:28:in `auto_activate'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extension_manager.rb:20:in `block (2 levels) in initialize'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/callback_manager.rb:57:in `instance_exec'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/callback_manager.rb:57:in `block in execute'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/hamster-3.0.0/lib/hamster/vector.rb:1316:in `each'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/hamster-3.0.0/lib/hamster/vector.rb:1316:in `traverse_depth_first'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/hamster-3.0.0/lib/hamster/vector.rb:431:in `each'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/callback_manager.rb:57:in `execute'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/contracts-0.13.0/lib/contracts/method_reference.rb:43:in `send_to'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/contracts-0.13.0/lib/contracts/call_with.rb:76:in `call_with'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/contracts-0.13.0/lib/contracts/method_handler.rb:138:in `block in redefine_method'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/callback_manager.rb:28:in `block in install_methods!'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/application.rb:280:in `initialize'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-cli-4.4.2/bin/middleman:49:in `new'
	from /Users/levinotik/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-cli-4.4.2/bin/middleman:49:in `<top (required)>'
	from /Users/levinotik/.rbenv/versions/3.1.2/bin/middleman:25:in `load'
	from /Users/levinotik/.rbenv/versions/3.1.2/bin/middleman:25:in `<main>'

Same as above - middleman init is throwing the same error for me

I ran into this issue today (2022-10-12) on a fresh middleman install.

I started with Ruby version 3.1.2 and middleman init could not complete, and I got the haml error described.

Then I dropped down to Ruby version 3.0.3 and middleman init completed. Then bundle exec middleman server gave me the haml error.

The workaround provided here solved the issue for me, but recent commits don't seem to have solved the issue, at least not for me.

Same issue.

  • Ruby 3.1.2 installed via chruby
  • Middleman 4.4.2
  • macOS 12.6 (M1)

I'm still having the same issue even with the fix mentioned above running into this error when I run middleman init:
/Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/renderers/haml.rb:49:in `initialize': uninitialized constant Haml::Options (NameError)

    ::Haml::Options.defaults[:context] = nil
          ^^^^^^^^^
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extension_manager.rb:66:in `new'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extension_manager.rb:66:in `activate'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extensions.rb:120:in `block in auto_activate'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/3.1.0/set.rb:511:in `each_key'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/3.1.0/set.rb:511:in `each'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extensions.rb:117:in `auto_activate'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extension_manager.rb:28:in `auto_activate'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/extension_manager.rb:20:in `block (2 levels) in initialize'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/callback_manager.rb:57:in `instance_exec'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/callback_manager.rb:57:in `block in execute'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/hamster-3.0.0/lib/hamster/vector.rb:1316:in `each'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/hamster-3.0.0/lib/hamster/vector.rb:1316:in `traverse_depth_first'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/hamster-3.0.0/lib/hamster/vector.rb:431:in `each'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/callback_manager.rb:57:in `execute'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/contracts-0.13.0/lib/contracts/method_reference.rb:43:in `send_to'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/contracts-0.13.0/lib/contracts/call_with.rb:76:in `call_with'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/contracts-0.13.0/lib/contracts/method_handler.rb:138:in `block in redefine_method'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/callback_manager.rb:28:in `block in install_methods!'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-core-4.4.2/lib/middleman-core/application.rb:280:in `initialize'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-cli-4.4.2/bin/middleman:49:in `new'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/middleman-cli-4.4.2/bin/middleman:49:in `<top (required)>'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/bin/middleman:25:in `load'
    from /Users/akhildamarla/.rbenv/versions/3.1.2/bin/middleman:25:in `<main>'

Hello everyone 👋🏼 The fix was already merged (in both branches, 4.x and 5.x), but still not released, see:

In the meantime, you can point the gem to GitHub 4.x branch:

gem 'middleman', github: 'middleman', branch: '4.x'

Or if you are already using on 5.x:

gem 'middleman', github: 'middleman', branch: 'master'

see also: #2588

Could we possibly release master as 5.0.0.rc2 as a first Haml 6-compatible version?

hi @k0kubun 👋🏼

I had a conversation yesterday with @tdreyno, about this weird situation between v4 and v5.

We came up with some ideas. Maybe we should do the following?

  • release current master as v5.0.0.rc2
  • move current master to a new v5 branch
  • move v4 to master again

Sounds good!

I also prepared a backport to the current 4.x branch #2590. Please consider merging (and releasing) it before or after the rename.