Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editing config.rb while server is running and then exiting crashes Middleman #1430

Closed
kasper opened this issue Jan 22, 2015 · 18 comments
Closed

Comments

@kasper
Copy link

kasper commented Jan 22, 2015

Editing config.rb while server is running and then exiting crashes Middleman 3.3.7 on Yosemite 10.10.1 and Ruby 2.2.0.

middleman-site $ bundle exec middleman
== The Middleman is loading
== The Middleman is standing watch at http://0.0.0.0:4567
== Inspect your site configuration at http://0.0.0.0:4567/__middleman/
== The Middleman is reloading
== The Middleman has reloaded
^C/Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:333:in `cleanup_shutdown_pipe': undefined method `each' for nil:NilClass (NoMethodError)
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:202:in `block in start'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:32:in `start'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:162:in `start'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/middleman-core-3.3.7/lib/middleman-core/preview_server.rb:36:in `block in start'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/middleman-core-3.3.7/lib/middleman-core/preview_server.rb:35:in `loop'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/middleman-core-3.3.7/lib/middleman-core/preview_server.rb:35:in `start'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/middleman-core-3.3.7/lib/middleman-core/cli/server.rb:78:in `server'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/middleman-core-3.3.7/lib/middleman-core/cli.rb:72:in `method_missing'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:29:in `run'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:126:in `run'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/middleman-core-3.3.7/lib/middleman-core/cli.rb:20:in `start'
    from /Users/Kasper/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/middleman-core-3.3.7/bin/middleman:18:in `<top (required)>'
    from /Users/Kasper/.rbenv/versions/2.2.0/bin/middleman:23:in `load'
    from /Users/Kasper/.rbenv/versions/2.2.0/bin/middleman:23:in `<main>'
@tdreyno
Copy link
Member

tdreyno commented Jan 22, 2015

Thanks for reporting

@alex88
Copy link
Contributor

alex88 commented Jan 23, 2015

I'm running a different but maybe related issue, when saving config.rb and running middleman server --verbose I get:

== The Middleman is standing watch at http://0.0.0.0:4567
== Inspect your site configuration at http://0.0.0.0:4567/__middleman/
[2015-01-23 12:07:35] INFO  WEBrick::HTTPServer#start: pid=25315 port=4567
[2015-01-23 12:07:39] INFO  going to shutdown ...
[2015-01-23 12:07:39] INFO  WEBrick::HTTPServer#start done.
== The Middleman is reloading
== Activating: sprockets
== Reading:  Local config
== Activating: gzip
== Activating: s3_sync
== Activating: blog
== Activating: livereload
Loaded extensions:
== Extension: sprockets
== Extension: gzip
== Extension: s3_sync
== Extension: blog
== Extension: livereload
== Extension: frontmatter
== File Change: circle.yml
......... removed due verbosity ...........
== File Change: source/works.haml
== Rebuilding resource list
== The Middleman has reloaded
[2015-01-23 12:07:39] INFO  WEBrick::HTTPServer#start: pid=25315 port=4567
[2015-01-23 12:07:39] ERROR NoMethodError: undefined method `[]' for nil:NilClass
    /usr/local/var/rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:174:in `block in start'
== LiveReload accepting connections from http://192.168.0.150:35729
[2015-01-23 12:07:39] ERROR NoMethodError: undefined method `[]' for nil:NilClass
    /usr/local/var/rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:174:in `block in start'

and goes on with the undefined method error continuously

@kasper
Copy link
Author

kasper commented Jan 23, 2015

@alex88 I’m seeing that also for example when changing livereload settings while the server is running. See middleman/middleman-livereload#71 (comment).

@alex88
Copy link
Contributor

alex88 commented Jan 23, 2015

@kasper I got that issue even without changing them, just by saving the config.rb file without changes

@kasper
Copy link
Author

kasper commented Jan 23, 2015

@alex88 Yes, that also is enough.

@alex88
Copy link
Contributor

alex88 commented Jan 23, 2015

I've just tried without the livereload activated and the issue is the same

update: tried also without having the gem in Gemfile, same behaviour

@tdreyno
Copy link
Member

tdreyno commented Jan 23, 2015

Yeah, I think something may have changed slightly with Webrick... will investigate.

nhemsley added a commit to nhemsley/middleman that referenced this issue Mar 8, 2015
This fixes the bug referenced.
It may be somewhat broken, and perhaps this should be in unmount_instance.

Basically what is happening is that the ensure block in Webrick.start runs, setting @shutdown_pipe to nil, then it tries to remount with a broken @webrick. Im not sure shy the ensure block is running exactly though...
@nhemsley
Copy link

nhemsley commented Mar 8, 2015

This PR fixes the problem by stopping the webrick instance & recreating one on reload.

Probably wrong, but it may give someone with more of a clue why this is happening.

The PR has more info why this bug is happening.

@tdreyno tdreyno closed this as completed Mar 23, 2015
@alex88
Copy link
Contributor

alex88 commented Mar 24, 2015

@tdreyno when will you release the version with this fix?

@tdreyno
Copy link
Member

tdreyno commented Mar 24, 2015

There was no change. As per: #1475 (comment) this was a bug in Ruby 2.2.0 which is fixed here (ruby/ruby@ab0a64e)

I guess we're waiting for Ruby 2.2.2

@alex88
Copy link
Contributor

alex88 commented Mar 24, 2015

Oh great, I misread the comment and I thought you merged the fix

@ashlynbaum
Copy link

I'm using 2.2.2 and I still have the bug.

@tdreyno tdreyno reopened this May 11, 2015
tdreyno added a commit that referenced this issue May 11, 2015
@tdreyno
Copy link
Member

tdreyno commented May 11, 2015

@ashlynbaum Can you point your Gemfile at Github v3-stable branch? Let me know if it's fixed now.

@ashlynbaum
Copy link

@tdreyno That did fix the bug, thanks.

@nhemsley
Copy link

@tdreyno works for me.

@RickMeijer
Copy link

Just an FYI for people coming in via Google:
Fixed in 3.3.13, which was yanked from rubygems.org. So you need to point to the repo in your Gemfile (gem 'middleman', github: 'middleman/middleman', branch: 'v3-stable').

@johnrlive
Copy link

I commented out the following and the error went away. Not sure why, anyone care enough to explain?

#require 'rubygems'
#require 'middleman/rack'
#run Middleman.server

@sandstrom
Copy link
Contributor

I'm doing some issue-gardening 🌿🌷🌾 and came across this issue.

This should be fixed and the issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants