middleman / middleman-livereload

LiveReload support for Middleman
http://middlemanapp.com
MIT License
117 stars 39 forks source link

middleman-livereload 3.1.0 not working with middleman 3.2.0 #34

Closed minasmart closed 10 years ago

minasmart commented 11 years ago

The very first line in my config is:

activate :livereload, :apply_js_live => false

However livereload calls never hit the browser. When I start up middleman server

bundle exec middleman server --verbose

I see the message

== LiveReload is waiting for a browser to connect

But I never see the message "== Livereload browser connected" after I open the page in my browser.

I do, however, see the == LiveReloading path: ... messages.

Any ideas?

My Gemfile looks like this:

gem "middleman", "~> 3.2.0"
gem "middleman-livereload", "~> 3.1.0"
tdreyno commented 11 years ago

Nothing related to that should have changed... If you revert to Middleman 3.1.x do things work again?

minasmart commented 11 years ago

It worked in 3.1.6, and I can make it work in 3.2.0, with caveats: you must set both :apply_js_live => false, :apply_css_live => false in order for it to work. One or none set to false and it doesn't work properly. Maybe it's upstream with the rack livereload middleware?

tdreyno commented 11 years ago

You're right, I don't see the connect message on my own projects, but the live reload still works.

minasmart commented 11 years ago

Very weird. The refresh events only fire when I have both set to false still. Is there anything I do to verify the web socket is connected and receiving data?

gasatrya commented 11 years ago

I just updated to middleman 3.2.0 and I only got error message

== The Middleman is loading
C:/Ruby200/lib/ruby/gems/2.0.0/gems/http_parser.rb-0.5.3-x86-mingw32/lib/ruby_ht
tp_parser.rb:2:in `require': cannot load such file -- 2.0/ruby_http_parser (Load
Error)
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/http_parser.rb-0.5.3-x86-mingw3
2/lib/ruby_http_parser.rb:2:in `<top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/http_parser.rb-0.5.3-x86-mingw3
2/lib/http_parser.rb:2:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/http_parser.rb-0.5.3-x86-mingw3
2/lib/http_parser.rb:2:in `<top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/http_parser.rb-0.5.3-x86-mingw3
2/lib/http/parser.rb:1:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/http_parser.rb-0.5.3-x86-mingw3
2/lib/http/parser.rb:1:in `<top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/em-websocket-0.5.0/lib/em-webso
cket/handshake.rb:1:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/em-websocket-0.5.0/lib/em-webso
cket/handshake.rb:1:in `<top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/em-websocket-0.5.0/lib/em-webso
cket.rb:15:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/em-websocket-0.5.0/lib/em-webso
cket.rb:15:in `block in <top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/em-websocket-0.5.0/lib/em-webso
cket.rb:14:in `each'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/em-websocket-0.5.0/lib/em-webso
cket.rb:14:in `<top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-livereload-3.1.0/lib/
middleman-livereload/reactor.rb:1:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-livereload-3.1.0/lib/
middleman-livereload/reactor.rb:1:in `<top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-livereload-3.1.0/lib/
middleman-livereload/extension_3_1.rb:2:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-livereload-3.1.0/lib/
middleman-livereload/extension_3_1.rb:2:in `<top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-livereload-3.1.0/lib/
middleman-livereload.rb:6:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-livereload-3.1.0/lib/
middleman-livereload.rb:6:in `block in <top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/extensions.rb:46:in `call'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/extensions.rb:46:in `load'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/core_extensions/extensions.rb:103:in `activate'
        from D:/xampp/htdocs/html-theme/newdangdoothtml/config.rb:51:in `initial
ize'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/core_extensions/extensions.rb:162:in `instance_eval'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/core_extensions/extensions.rb:162:in `initialize'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/core_extensions/data.rb:35:in `initialize'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/application.rb:169:in `initialize'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/core_extensions/request.rb:50:in `new'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/core_extensions/request.rb:50:in `inst'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/preview_server.rb:102:in `new_app'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/preview_server.rb:20:in `start'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/cli/server.rb:79:in `server'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb
:27:in `run'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation
.rb:120:in `invoke_command'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor.rb:363:in
`dispatch'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/base.rb:43
9:in `start'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/cli.rb:77:in `method_missing'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb
:29:in `run'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb
:128:in `run'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation
.rb:120:in `invoke_command'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor.rb:363:in
`dispatch'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/base.rb:43
9:in `start'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/lib/middle
man-core/cli.rb:22:in `start'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/middleman-core-3.2.0/bin/middle
man:18:in `<top (required)>'
        from C:/Ruby200/bin/middleman:23:in `load'
        from C:/Ruby200/bin/middleman:23:in `<main>'

Reinstall http_parser.rb, no luck.

config.rb activate :livereload, :host => '127.0.0.1'

gemfile.lock

middleman (~> 3.2.0)
middleman-livereload (~> 3.1.0)

gemfile

source 'http://rubygems.org'

gem "middleman", "~>3.2.0"
gem "middleman-livereload", "~>3.1.0"

# Compass plugins
gem "susy", "~> 1.0.9" # Susy

# For faster file watcher updates:
gem "wdm", "~> 0.1.0" # Windows

# Cross-templating language block fix for Ruby 1.8
platforms :mri_18 do
  gem "ruby18_source_location"
end
tdreyno commented 11 years ago

Looks like this is an issue further up the stack: https://github.com/igrigorik/em-websocket/issues/102

Seems like the solution, until em-websocket releases a new version, is to use their version directly from github. Try adding the following to your Gemfile:

gem "em-websocket", :github => "igrigorik/em-websocket"
gasatrya commented 11 years ago

Thanks @tdreyno but then i got this error.

D:\xampp\htdocs\html-theme\newdangdoothtml>bundle update
Fetching git://github.com/igrigorik/em-websocket.git
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/source/git/git_pro
xy.rb:88:in ``': No such file or directory - git clone "git://github.com/igrigor
ik/em-websocket.git" "C:/Ruby200/lib/ruby/gems/2.0.0/cache/bundler/git/em-websoc
ket-14f9aa25f99f74ac2518bd6cace2da80a57377a5" --bare --no-hardlinks (Errno::ENOE
NT)
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/sourc
e/git/git_proxy.rb:88:in `git'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/sourc
e/git/git_proxy.rb:49:in `checkout'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/sourc
e/git.rb:144:in `specs'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/defin
ition.rb:493:in `block in converge_locked_specs'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/defin
ition.rb:482:in `each'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/defin
ition.rb:482:in `converge_locked_specs'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/defin
ition.rb:167:in `resolve'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/defin
ition.rb:114:in `specs'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/defin
ition.rb:109:in `resolve_remotely!'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/insta
ller.rb:83:in `run'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/insta
ller.rb:14:in `install'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/cli.r
b:320:in `update'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/vendo
r/thor/task.rb:27:in `run'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/vendo
r/thor/invocation.rb:120:in `invoke_task'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/vendo
r/thor.rb:344:in `dispatch'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/vendo
r/thor/base.rb:434:in `start'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/bin/bundle:20:in
`block in <top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/frien
dly_errors.rb:3:in `with_friendly_errors'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/bin/bundle:20:in
`<top (required)>'
        from C:/Ruby200/bin/bundle:23:in `load'
        from C:/Ruby200/bin/bundle:23:in `<main>'
tdreyno commented 10 years ago

Try again? Maybe something just timed out?

gasatrya commented 10 years ago

@tdreyno I tried several times, but no luck :(

lolmaus commented 10 years ago

Did you try this?

gem "http_parser.rb", "~> 0.6.0.beta.2"
gasatrya commented 10 years ago

Just downgrade my ruby to 1.9.3 and everything works fine. @tdreyno you right, ruby 2.0 messed up with windows.

amalagaura commented 10 years ago

Adding :apply_js_live => false, :apply_css_live => false made it work for me with Ruby 2.0 and middleman (3.1.6) middleman-livereload (3.1.0)

Was not working without that even if file changed was not JS or CSS.

marcelosomers commented 10 years ago

+1 on this issue. Adding the websockets gem as @tdreyno referenced above seemed to fix the issue, although it forces a refresh of the page and doesn't inject CSS changes live.

bhollis commented 10 years ago

Workaround has been documented in the README.