middleman/middlemanapp.com

config.ru instructions do not seem to work

rafaelgonzalez opened this issue ยท 4 comments

Hello ๐Ÿ‘‹

I have encountered an issue when setting up Middleman to run through Rack. Specifically these instructions on the "Start New Site" page:

you can add a config.ru file at the root of your project with the following contents:

require 'middleman/rack'
run Middleman.server

This didn't work for me with the following command: bundle exec rackup config.ru. I get the following error:

config.ru:2:in `block in <main>': undefined method `server' for Middleman:Module (NoMethodError)

After looking through the code in Middleman:Rack, I've come up with the following which works:

require 'middleman-core/rack'
require 'middleman-autoprefixer'

run Middleman::Rack.new(Middleman::Application.new)

I have to require middleman-autoprefixer, otherwise I get the following error when running the command above:

Unknown Extension: autoprefixer. Check the name and make sure you have referenced the extension's gem in your Gemfile. (RuntimeError)

I appreciate this is not really a scenario that should be used to run Middleman, as the instructions say. I am not sure whether the instructions are obsolete, or if something I'm doing wrong, but I hope all the above can help!

Hi, which version of Middleman are you running? Can you also share the pieces of your Gemfile which specify Middleman?

This should work... its just so rarely used that a regression may have snuck in.

Hey @tdreyno, thanks for your reply. Here's the Gemfile bit that specifies Middleman:

gem 'middleman', '~> 4.2'
gem 'middleman-autoprefixer', '~> 2.7'
gem 'tzinfo-data', platforms: %i[mswin mingw jruby]
gem 'wdm', '~> 0.1', platforms: %i[mswin mingw]

I've essentially retained whatever middleman init generated and added back my other dependencies in.

  1. It definitely appears the server helper method has gone missing.

  2. How are you starting the Rack server? Having to manually require autoprefixer makes me think bundle isn't in play.

I've restored the old api (middleman/middleman@e85bc85), and will get that out VERY SOON (waiting for bundler v2 to do a new release).

  1. Phew so I wasn't going mad! ๐Ÿ˜…

  2. I'm transitioning an app to Middleman. It's a very simple Sinatra app booted up with Rack that does not need to be dynamic anymore. But because the current stack uses Rack, I would like to still be able to boot it up that way until the Sinatra->Middleman transition is complete (e.g. how the views are built from JSON data). This is only to make the transition smoother, eventually Rack will be scraped entirely. So yeah, pretty marginal case.

I've restored the old api (middleman/middleman@e85bc85), and will get that out VERY SOON (waiting for bundler v2 to do a new release).

Thanks! No rush from my end.