Debugging Middleman using RubyMine

In order to debug Middleman, you can run the server from within RubyMine.

Setting up

Select Run > Edit Configuration… and fill in:

[Configuration-tab]

Name: Middleman development server (or whatever you prefer)

Ruby script:
/Users/Tommy/.rvm/gems/ruby-1.9.3-p194@tools-middleman-html5bp-haml/gems/middleman-core-3.0.5/bin/middleman
(change to the path of your server. IMPORTANT: You must adjust this everytime you change the version of Middleman or Ruby that you are using.)

Working directory: /Users/Tommy/Sites/Middleman/anvandbart.se (change to the
path to your site)

[Bundler-tab]

Select ’Run the script in context of the bundle (bundle exec) (Most of
the time it works without doing this)

Debugging

Remember to first shut down any other instance of the server that you have running

Now you can start the server using Run > Debug ‘Middleman development server’.

Set your breakpoints.

And when you load a page in the web browser, it will stop when you reach a breakpoint. Switch to RubyMine and introspect away.

(Added: In my experience there are some limitations though. The sitemap (and things with references to it) is big and sometimes the RubyMine debugger seams to choke on it.)

Debugging the build process

As above, but in the ”Script arguments” field, write ”build”.