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

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I also prepared a backport to the current 4.x branch https://github.com/middleman/middleman/pull/2590. Please consider merging (and releasing) it before or after the rename.

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'

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'

Same issue.

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

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