Coder Social home page Coder Social logo

guard / guard-livereload Goto Github PK

View Code? Open in Web Editor NEW
2.1K 44.0 146.0 198 KB

Guard::LiveReload automatically reload your browser when 'view' files are modified.

Home Page: https://rubygems.org/gems/guard-livereload

License: MIT License

Ruby 44.70% JavaScript 55.30%

guard-livereload's Introduction

⚠️ ⚠️ ⚠️ Security Vulnerability: please upgrade to v2.5.2 - details here . (Credits: Michael Coyne)

Guard::LiveReload

Gem Version Build Status Dependency Status Code Climate Coverage Status Join the chat at https://gitter.im/guard/guard-livereload

LiveReload guard allows to automatically reload your browser when 'view' files are modified.

Support

⚠️ Guard::LiveReload is looking for a new maintainer. Please contact me if you're interested.

For any support question/issue related to livereload please ask on [email protected].

Install

Please be sure to have Guard installed before continuing.

Install the gem:

$ gem install guard-livereload

Add it to your Gemfile (inside development group):

group :development do
  gem 'guard-livereload', '~> 2.5', require: false
end

Add guard definition to your Guardfile by running this command:

$ guard init livereload

And to get everything running in the browser, use rack-livereload or install the LiveReload Safari/Chrome/Firefox extension.

Usage

For a quick start, check out the wiki.

If you're using Rails or Rack based apps, check out rack-livereload how it works readme section.

For info about Guard and it's plugins, see Guard usage doc

For more info about LiveReload extensions, see LiveReload extension usage doc from version 1.x

Guardfile

You can adapt your 'view' files like you want. Please read Guard doc for more info about Guardfile DSL.

guard 'livereload' do
  watch(%r{app/views/.+\.(erb|haml|slim)})
  watch(%r{app/helpers/.+\.rb})
  watch(%r{public/.+\.(css|js|html)})
  watch(%r{config/locales/.+\.yml})
  # Rails Assets Pipeline
  watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html))).*}) { |m| "/assets/#{m[3]}" }
end

Options

LiveReload guard has 6 options that you can set like this:

guard 'livereload', grace_period: 0.5, override_url: true do
  # ...
end

Available options:

notify: true          # default false
host: '127.3.3.1'     # default '0.0.0.0'
port: '12345'         # default '35729'
apply_css_live: false # default true
override_url: false   # default false
grace_period: 0.5     # default 0 (seconds)
js_template: './my_livereload.js.erb' # default is livereload.js.erb from gem

Additional custom JS template options (see livereload.js.erb for details):

js_apple_webkit_extra_wait_time: 50 # default is 5 (see issue #123)
js_default_extra_wait_time: 100 # default is 200

notify uses Guard's system notifications. See LiveReload configuration doc from version 1.x for more info about other options.

Troubleshooting

To work out what's wrong and where, just follow this easy guide: https://github.com/guard/guard-livereload/wiki/Troubleshooting

Other issues:

1. "hw.ncpu" is an unknown key.

Solution: just upgrade the listen gem to '3.x' (Listen is used by Guard).

(Details: #134)

Development

Pull requests are very welcome! Please try to follow these simple "rules", though:

  • Please create a topic branch for every separate change you make.
  • Make sure your patches are well tested.
  • Update the README (if applicable).
  • Please do not change the version number.

For questions please join us on our Google group or on #guard (irc.freenode.net).

Author

Thibaud Guillaume-Gentil

guard-livereload's People

Contributors

aaronjensen avatar alexcrichton avatar andreyvit avatar assembler avatar dalyons avatar e2 avatar felixbuenemann avatar fnichol avatar fwoeck avatar gma avatar isotes avatar jadencarver avatar jibiel avatar jonmast avatar kossnocorp avatar mohhasbias avatar narkoz avatar nemodreamer avatar nv avatar robert2d avatar rymai avatar salimane avatar sigmike avatar silvenon avatar tdreyno avatar thibaudgg avatar wkrsz avatar yachi avatar zoras avatar zzeroo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

guard-livereload's Issues

Trouble Connecting in Chrome

LiveReload can't connect to the guard server unless I install gem install em-websocket.

Just thought someone would find this interesting.

Reloading Sass file displays partially unstyled page on Rails 3.1

Anybody faced with a similar issue?

I'm thinking Sass is taking a bit too long to compile maybe and it's reloading before the CSS is ready. I find myself having to Command+S a few times to get the browser to display the page with CSS again.

Flow

  1. Save Sass (style.css.sass) changes with Command + S
  2. Guard notices
Reloading browser: app/assets/stylesheets/style.css app/assets/stylesheets/style.css
  1. All the styles from style.css.sass disappear after the page reload
  2. A second Command + S displays all updated styles.

Versions

  • Guard 0.8.3
  • guard-livereload 0.3.1
  • rb-fsevent 0.4.3.1

guard-livereload never connects to safari/chrome (using pow.cx)

I've been trying to get livereload to work with my Rails app. I visit my app using pow's myapp.dev. I still have a default 3.1 app so there I see my index.html "welcome to Rails ...".

I see my guard saying "waiting for browser to connect"

I enable livereload in both safari and chrome, using the latest extensions, I don't get any errors there, but I also don't get any connect message in Guard. I also checked if the ports being used are the same for all, they are.

Now, when I edit index.html, I get a guard message saying "Reloading browser: public/index.html", but when I check my browsers (both), nothing has changed.

I also tried using rack-livereload, but same results there.

Configuration Overwriting

I've noticed that this line:

https://github.com/guard/guard-livereload/blob/master/lib/guard/livereload.rb#L14

would overwrite a configuration option of :apply_js_live => false because false is seen as being false and the write will occur. Here's what I did in irb:

>> a = {:a => false}
=> {:a=>false}
>> a[:a] ||= true
=> true
>> a
=> {:a=>true}

I think this should rather be:

options[:apply_js_live] = true unless options.key?(:apply_js_live)

Also the same for :apply_css_live I would imagine.

Let browser wait with reload until assets are finished compiling

A very useful gem, thank you!

One thing: when I change something in a rather big screen.css.scss file and Rails needs some time to compile it, then immediately after saving the file, the browser displays everything without the CSS of the file (only plain HTML), and a few secons later it reloads it with the correct CSS.

This isn't really a big problem, but it would be nice to see the change from the old CSS to the new CSS without interruption (this would allow comparing subtle differences on the fly).

I don't know a lot about the assets, but maybe when saving the CSS file, the old compiled one first gets deleted, which notifies livereload to update, then the new one gets compiled and saved a few seconds later, which again notifies livereload. Maybe this process can be optimized.

Anyway, thanks a lot for this wonderful gem!

PS: I use rack-livereload, if this is of any importance.

run order

I don't know if there's a good solution to this, but even with a test suite run of say ~30s, it's annoying (and defeats the purpose) to have to wait for the test suite to finish before the page reloads.

How I'm currently dealing with this is to separate out into groups livereload and everything else. Then I run a guard process for each group.

It would be nice if somehow guard-livereload could happen asynchronously, but If there's a better way to do this presently let me know!

Chrome not refreshing page, but all looks fine

I run bundle exec guard

Guard uses Libnotify to send notifications.
Guard is now watching at '/home/rege/rails_projects/hksklep'
LiveReload 1.6 is waiting for a browser to connect.
Browser connected.
Browser URL: http://0.0.0.0:4567/
Reloading browser: public/custom.js
> 

All looks fine but Chrome not refreshing page.

My Guard version is Guard version 0.10.0
And lastest chrome.

How to dectect where the problem is?
This is a sinatra project.

guard-livereload not live refreshing CSS

Hello,

I am adding the following to my Guardfiles in order to use for non-Rails projects:

watch(%r{(css|html|js|php)})

The CSS is not live refreshing... it reloads the entire page. I tried adding ':apply_css_live => true', didn't help. Anything I am doing wrong?

guard-livereload with ubuntu, nothing is reloaded

Hello,
I'm not sure I'm at the right place for asking this question, so my apologies if it is not.

I'm trying to use guard-livereload with a plain html/js project.
I'm running ubuntu 12.04 so I did the following to install guard-livereload:

sudo apt-get install rubygems ruby-dev
sudo gem install guard-livereload

Then I did a guard init in my project folder to create the Guardfile.
I modified the content and put the following:

guard 'livereload' do
  watch(%r{app/.*})
end

And then I run guard, change something in the app folder, and here is the output

letters [master●] % guard
14:59:27 - INFO - Guard uses NotifySend to send notifications.
14:59:27 - INFO - Guard uses TerminalTitle to send notifications.
14:59:27 - INFO - LiveReload 1.6 is waiting for a browser to connect.
14:59:27 - INFO - Guard is now watching at '/home/bigx/repos/letters'
14:59:33 - INFO - Reloading browser: app/index.html
[WARNING] MultiJson is using the default adapter (ok_json). We recommend loading a different JSON library to improve performance.
[1] guard(main)> 

So it seems to be OK, isn't it?

On the browser side, I use either Chromium (18.0.1025.151) or Chrome (Version 26.0.1386.0 dev) with the LiveReload plugin (2.0.9). Click on the toolbar button and the hover message tells me:

LiveReload is connected, click to disable

And if I check the html code I see the link to the script:

<script src="http://127.0.0.1:35729/livereload.js?ext=Chrome&amp;extver=2.0.9"></script>

So the browser side seems also OK, but nothing is reloaded??

Did I miss something? Any idea?

And what is this reference to LiveReload 1.6 in the console?

Thanks in advance,

Regards,

Xavier

Guard-livereload in a vm

Hi,

I've recently moved my dev env into a headless VM running ubuntu server 11. I run it on MacOS 10.7.

My code is running in my vm and I do browser testing on my mac. Though, I cannot manage to connect Livereload to my VM. Do you have any idea how I could do that?

Thanks for your help!

Supporting LR 2.0?

Due to other non-rails development I've upgraded my browser plugins to 2.0. Any timeline for support in guard-livereload?

Thanks!
Gerald

Cannot get guard-livereload to work

Hi,

I have installed guard-livereload according to https://github.com/guard/guard-livereload, i.e. added gem 'guard-livereload' to my Gemfile and did bundle install. Guard starts it(I see "LiveReload 1.6 is waiting for a browser to connect.") when guard is launched but none of my browsers seems able to connect!

Firefox, Chrome and Safari says: Could not connect to LiveReload server. Please make sure that LiveReload 2 (or another compatible server) is running. Using Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:12.0) Gecko/20100101 Firefox/12.0, Chrome Version 19.0.1084.52 and Safari Version 5.1.7 (6534.57.2). I have installed the 2.08 extensions to all these browsers and from older closed issues I understood this combination should work, correct?

It seems it cannot find the server, cause in the Firefox error console I see an error message indicating it cannot connect to ws://127.0.0.1:35729/livereload.

And if I try to do "telnet localhost 35729" I get
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
telnet: Unable to connect to remote host

So there seems to be no server at that port. To make sure the server is started at that port I did configure this in the Guardfile:
guard 'livereload', :port => '35729'do but it does not help. Any ideas why the server isn't starting correctly or wont give any error messages?

FreeBSD: browser doesn't reload when guard says it is reloading it

I see this log, file was changed, guard says browser is reloading but it really doesn't reload.

-- begin log --
Browser connected.
Browser URL: http://localhost/my.html
Reloading browser: my.js
Reloading browser: my.js
-- end log --

It works sometimes. But sometimes it doesn't. I can't figure out the condition why.
Browser (chrome) shows it is connected (with green color).

I also found notify-send.core in the same directory. This might be the clue.

live reloading javascript files don't work for me

it seems that everything is working, but the code is not really updated
qwe

project hierarchy:

▸ images/
▾ javascripts/
    app.js
    utils.js
▾ stylesheets/
    common.css
  index.html
  README.md

guard config file:

guard 'livereload' do
  watch( %r{.+/.+\.(css|js)} )
  watch( %r{.+\.html} )
end

with other files (css and html) work ok

my system is ubuntu 12.04

Firefox 7.0.1 guard not recognized

In Firefox 7.0.1 with Windows 7, when I hit the LiveReload button, guard responds "Browser connected" but the browser reports "Could not connect to LiveReload server. Please make sure that a compatible LiveReload server is running. (We recommand guard-livereload, until LiveReload 2 comes to your platform.)"

When I connect from Chrome 15, I get "Browser connected" and then "Browser URL: http...."
I brought this up with the guys at Livereload, they said since Chrome was working, and guard was sort of responding to Firefox, "the problem is almost certainly on their (server) side."

I have done gem update for guard, guard-livereload and em-websocket

Any suggestions?
Ken

Edit: I updated guard to 0.8.8 and this added ←[0m at the beginning and end of each guard response AND Chrome ceased to reliably connect. If I wait several minutes after 'guard start' Chrome will connect. In this state, guard livereload announces it has found a change at localhost/folder/file.ext, then announces reloading browser, but there is a long delay.

Edit2: I removed livereload from Sublime Text 2 and Chrome was immediately recognized by guard. Nice. I then made a change, and it took 30 seconds to propagate to the URL. Not nice!

"vendor" in assets pipeline ignored

Javascripts & Stylesheets located in vendor/assets/ directory are ignored, but app/assets/ work good

guard 'livereload', host: '0.0.0.0' do
  watch(%r{app/views/.+\.(erb|haml|slim)})
  watch(%r{app/helpers/.+\.rb})
  watch(%r{public/.+\.(css|js|html)})
  watch(%r{config/locales/.+\.yml})
  # Rails Assets Pipeline
  watch(%r{(app|vendor)/assets/\w+/(.+\.(css|js|html)).*})  { |m| "/assets/#{m[2]}" }
end

I'm running a fresh app on Archlinux, MRI 1.9.3

Gems used: https://gist.github.com/fc5dacfc7d7161902265

I have no errors or trace so let me know if I can give more details

guard-livereload with Pow

Not sure if this is guard related or guard-livereload or livereload problem but I'll record it here.

When using Pow.cx as your development server when you try and connect via the LiveReload extension you get the message displayed

http://cl.ly/0y2t2H1v2z0L36113U2y

any ideas? It's solvable by having a normal rails server runnning on port 3000 but that defeats the purpose of Pow.

John.

guard-livereload (doing nothing) vs .livereload ok

Using this setup https://gist.github.com/730255 -- guard-livereload doesn't seem to be catching the changes in files generated by some other guard plugins. If I change those by hand (or command line), it works just fine. I don't remember if it was coffeescript -> javascript or the extra guard-shell step (javascript -> jim bundle). Anyway, I took the pain of recompiling ruby so that regular livereload 1.4 is ok again. Just thought you may want to know about the issue.

guard main

Hi,

I've got guard-livereload working perfectly on a Mac Lion. But on another (Snow Leopard) I've got an issue.

When I type guard, I get:

01:00:03 - INFO - Guard uses TerminalTitle to send notifications.
01:00:03 - INFO - Guard is now watching at '/Users/romuald/Documents/devserver/temp/tgr'
01:00:03 - INFO - LiveReload 1.6 is waiting for a browser to connect.
[1] guard(main)> 01:00:21 - INFO - Browser connected.
01:00:21 - INFO - Browser URL: http://localhost/temp/tgr/
[1] guard(main)>
[1] guard(main)>
01:00:37 - INFO - Run all
[2] guard(main)>

As you can see the program seems interrupted by "guard(main)" and is waiting for something, which I don't see on the computer (the one where it works).

It looks like the chrome plugin livereload connects successfully, but when I save a file, it is going back on this guard(main) line and the browser doesn't reload.

I don't know anything about ruby btw... Any idea?

My version of ruby is 1.9.3

Gemfile:
source "http://rubygems.org"
group :development do
gem 'guard'
gem 'guard-livereload'
gem 'rb-fsevent', :require => false
end

Guardfile:
guard 'livereload', :apply_js_live => false, :apply_css_live => true do
watch(%r{lab/.+.(css|js|html)$})
end

Thanks

Romu

Incompatible Chrome Extension?

I see this error whenever I connect.

error

Is it possible to get this upgraded to the latest version of livereload?

Thanks!

background guard stops on FreeBSD when file change event occurs

$ guard 2>/dev/null > /dev/null &
[1] 30953
$ jobs
[1]+ Running guard 2> /dev/null > /dev/null &
$ touch xxx.html

[1]+ Stopped guard 2> /dev/null > /dev/null

Not clear why it stops. nohup doesn't help for some reason too. This makes guard unusable as a background process.

So I have to open another terminal just for guard to run -- this is not cool.

Vim .swp file detected as file change

some vim's swp files detected as file change because it contains erb extension. for example
app/views/layouts/.application.html.erb.swp

my current fix is by changing this line

  watch(%r{app/views/.+\.(erb|haml|slim)})

to this line

  watch(%r{app/views/.+\.(erb|haml|slim)$})

i think, the regex should be modified to make sure that the valid extension (erb, haml, slim) is at the end of string.

CMIIW. please forgive my writing. english is not my native language.

http_parser.rb in Gemfile

Couldn't run without this
gem 'http_parser.rb' in Gemfile
errors were:

00:52:29 - ERROR - Could not load 'guard/livereload' or find class Guard::Livereload
00:52:29 - ERROR - cannot load such file -- http/parser
00:52:29 - ERROR - Invalid Guardfile, original error is:
> [#] undefined method `new' for nil:NilClass

Gemfile was

source 'https://rubygems.org'
group :development do
  gem 'guard'
  gem 'rb-inotify', :require => false
  gem 'rb-fsevent', :require => false
  gem 'rb-fchange', :require => false
  gem 'guard-livereload'
  gem 'guard-bundler'
  gem 'http_parser.rb'
  gem 'guard-haml'
end

Eventmachine issues: Not installing on win7

The bundled eventmachine gem is trying to install it's latest release (0.12.10) which has known issues on windows.
Eventmachine can be installed using
gem "eventmachine", "1.0.0.beta.4.1"

But that doesn't help when trying to install guard-livereload, as it doesn't recognise eventmachine already existing and constantly errors trying to get eventmachine (0.12.10).

Is there a way guard-livereload could check the operating system and install the appropriate version on the fly?

Overwriting the INT and TERM handlers

Guard uses the INT and TERM signals to call the stop and run_all methods for each guard, but guard-livereload uses the start method of EventMachine::Websocket, which sadly, in a line installs it's own INT and TERM handlers. This causes the handlers installed by guard to never be called when guard exits.

I wasn't sure if this issue should be opened up here or there, but I decided that that's probably desirable for most uses of the websocket, and with guard is it only necessary to not overwrite the already installed handlers.

I was thinking maybe instead of EventMacine::Websocket.start, the same code could be used in the boot up of the websocket server by just calling directly

EventMachine::start_server(options[:host], options[:port], 
        EventMachine::WebSocket::Connection)

with the same specified block.

Do you agree or do you think this is an issue with the em-websocket gem instead?

Chrome not refreshing page, but all looks fine

I run bundle exec guard

Guard uses Libnotify to send notifications.
Guard is now watching at '/home/rege/rails_projects/hksklep'
LiveReload 1.6 is waiting for a browser to connect.
Browser connected.
Browser URL: http://0.0.0.0:4567/
Reloading browser: public/custom.js
> ``
All looks fine but Chrome not refreshing page.

My Guard version is ```Guard version 0.10.0```
And lastest chrome.

How to dectect where the problem is?

Chrome not refreshing page, but all looks fine

I run bundle exec guard

Guard uses Libnotify to send notifications.
Guard is now watching at '/home/rege/rails_projects/hksklep'
LiveReload 1.6 is waiting for a browser to connect.
Browser connected.
Browser URL: http://0.0.0.0:4567/
Reloading browser: public/custom.js
> 

All looks fine but Chrome not refreshing page.

My Guard version is Guard version 0.10.0
And lastest chrome.

How to dectect where the problem is?

How to get vbox guest to connect?

I have a local Ubuntu environment with vhosts setup for my sites, ie loc.example.com. In my IE8 vbox I configured the hosts file to map 10.0.2.2 to loc.example.com and it accesses the site great. I got the livereload.js script to embed on the page with the Drupal module but it still says waiting for browser to connect?

On the host OS it works fine but even though the guest gets the page with the livereload.js file it doesn't connect to guard. Is there any workaround for this?

Thanks

Firefox can't establish a connection to the server at ws://localhost:35729/livereload.

guard-livereload is awesome, i love the way it works. And is working for me as it should. But however i am not going to run the guard server all the time because i don't want it to be a strict development dependency.

Alright, problem for me is, in the firefox console, i am getting the this error

Firefox can't establish a connection to the server at ws://localhost:35729/livereload.

As we all use firebug console to debug the js issues, having this issue in the list all the time is irritating. Am i missing anything, or anything can be done to get rid of this?

Thanks in advance!

CSS generated from Sass reloads by refresh

It would be nice if there was a way in the Guardfile to indicate that a matching file is supposed to be reloaded without a page refresh. As it stands, Sass/SCSS changes cause a full browser reload.

Error while installing guard-livereload

sudo gem install guard-livereload
Building native extensions. This could take a while...
ERROR: Error installing guard-livereload:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- mkmf (LoadError) from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
from extconf.rb:2:in `

'

I am running Ubuntu 12.10, any help would be appreciated

Only reloads once, and then will not reload again

I have not been having much success in getting LiveReload working.
I run Guard and then the first time I edit my haml file, the reload will work, after that no more messages get logged to the console and the live reload does not work. I am using Rack_LiveReload.

Here is a screenshot of the console:
image

Here is a screenshot of my guard file:
image.

and finally, here is a screenshot of development.rb:
image

Waiting for browser to connect

I am hanging on waiting for browser to connect. I am running this on a local apache server running drupal using this module to inject the js. http://drupal.org/project/livereload

My hosts file is overwritten as loc.example.com and the local site is only available via that url, 127.0.0.1 won't get to it, I try to put that in for a host override but no go. Any idea?

Use multi_json gem

Can we use multi_json gem to avoid a compiled dependency?

I've got a user-facing tool I'd like to be able to distribute without requiring Xcode to compile extensions.

Guard 1.1 release?

Is a release from this branch blocking on anything that I can help with?

How to use this in ubuntu with firefox on a php server?

I have read http://icoloma.blogspot.de/2012/06/using-livereload-on-linux.html

So far is working, i had to add a gem rm-inotify and install this what that was not mentioned inside tut.

So I am at the point where it says LiveReload 1.6 is waiting for a browser to connect.

I have the Firefox extension installed but it has no options at all. What should I do?

The official repo (from mozilla) points to another version what I found strange. Is this extension still supported? Because it's only safari and chrome extension are pointed out here.

What is this rack-livereload thing? Is this for when I run a ruby server only? If not how to use it just instead if the extension.

It's very confusing jumping through the net from all this sites and guthub repos. Someone says put the gem inside the dev group, another says no don't. I have no idea of ruby I just like to get my firefox to autoreload.

One central step by step tut like the site i linked, but up-to-date anywhere?

Browser does not connect

Hi,

I'm using guard version 1.3.3 and guard-reload 1.8.24 on Ubuntu 12.04. I've used apache mod_substitute to successfully insert the following snippet into my web pages, prepended on to the closing body tag:

<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/scripts/livereload.js"></' + 'script>')</script>

When I run guard, it tells me:

Guard uses NotifySend to send notifications.
Guard is now watching at '/var/www/codeigniter'
LiveReload 1.6 is waiting for a browser to connect.

All seems well. However, no browser seems to connect. The file is never found at http://codeigniter:35729/scripts/livereload.js (where codeigniter points to 127.0.0.1). http://codeigniter:80/scripts/livereload.js (served by apache) works just fine.

running telnet codeigniter 35729 produces the following:

Trying 127.0.0.1...
Connected to codeigniter.
Escape character is '^]'.

But no disconnection. Seems to be working.

nmap codeigniter does not list the port 35729.

netstat produces the following (only relevant lines shown):

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State  
tcp        0      0 codeigniter:54069       codeigniter:44360       ESTABLISHED
tcp        0      0 codeigniter:44360       codeigniter:54069       ESTABLISHED

Sometimes the IP addresses differ, but they are often close to 35729.

The firefox extension also does not produce any response.

The chrome extension also does not work, but produces the following output:

Browser connected.
Browser URL: {"command":"hello","protocols":["http://livereload.com/protocols/connection-check-1"]}
Browser disconnected.

The contents of my guard file are as follows:

guard 'livereload', :host => '127.0.0.1' do
  watch(%r{.+\.(html|js|php|css|gif|jpeg|jpg|png)$})
end

guard 'sass', :input => 'styles', :output => 'styles'

guard seems to be working, when I modify a scss file (e.g. touch styles/test.scss), the following is ouput:

    Sass [0.01s] test.scss -> test.css
Reloading browser: styles/test.css

But still no LiveReload functioning because no browser can connect. I don't know what the issue might be. Any help would be much appreciated.

Livereload doesn't work. Browser doesn't updates.

When I update a file nothing happens in Chrome. I have the latest version of guard + guard-livereload.

The console output:

17:41:49 - INFO - Guard uses TerminalTitle to send notifications.
17:41:49 - INFO - Guard is now watching at 'l:/www/web-apps/Calculator'
17:41:49 - INFO - LiveReload is waiting for a browser to connect.
[1] guard(main)> 17:41:51 - INFO - Browser connected.
You are using an old or stdlib version of json gem
Please upgrade to the recent version by adding this to your Gemfile:

  gem 'json', '~> 1.7.7'

17:41:51 - INFO - Browser connected.
17:41:58 - INFO - Reloading browser: index.html
[1] guard(main)>

I says that I should add gem 'json', '~> 1.7.7' to my gemfile.

  1. I don't have a gemfile.
  2. I created one and added it but it still didn't work.

And yes, I have the livereload extension installed.

Btw, it worked a month ago. But stopped working today when I updated all my gems.

"LoadError: cannot load such file -- 2.0/ruby_http_parser".

guard-livereload doesn't work for me. When I run guard I get this error:

$ guard
DL is deprecated, please use Fiddle
14:57:28 - INFO - Guard uses TerminalTitle to send notifications.
14:57:29 - ERROR - Guard::LiveReload failed to achieve its <start>, exception was:
> [#B530D13781CB] LoadError: cannot load such file -- 2.0/ruby_http_parser
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/http_parser.rb-0.5.3-x86-mingw32/lib/ruby_http
_parser.rb:2:in `<top (required)>'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in re
quire'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/http_parser.rb-0.5.3-x86-mingw32/lib/http_pars
er.rb:2:in `<top (required)>'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in re
quire'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/http_parser.rb-0.5.3-x86-mingw32/lib/http/pars
er.rb:1:in `<top (required)>'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:106:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:106:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/em-websocket-0.5.0/lib/em-websocket/handshake.
rb:1:in `<top (required)>'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:58:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:58:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/em-websocket-0.5.0/lib/em-websocket.rb:15:in `
block in <top (required)>'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/em-websocket-0.5.0/lib/em-websocket.rb:14:in `
each'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/em-websocket-0.5.0/lib/em-websocket.rb:14:in `
<top (required)>'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:58:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:58:in `require'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-livereload-1.1.3/lib/guard/livereload/re
actor.rb:1:in `<top (required)>'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-livereload-1.1.3/lib/guard/livereload.rb
:26:in `start'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:99:in `block i
n run_supervised_task'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:97:in `catch'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:97:in `run_sup
ervised_task'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:54:in `block (
2 levels) in run'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:175:in `block
(3 levels) in scoped_guards'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:174:in `each'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:174:in `block
(2 levels) in scoped_guards'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:173:in `catch'

> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:173:in `block
in scoped_guards'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:172:in `each'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:172:in `scoped
_guards'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:53:in `block i
n run'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/lumberjack-1.0.3/lib/lumberjack.rb:27:in `unit
_of_work'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/runner.rb:52:in `run'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard.rb:189:in `block in star
t'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard.rb:365:in `block in with
in_preserved_state'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard.rb:362:in `synchronize'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard.rb:362:in `within_preser
ved_state'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard.rb:187:in `start'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/lib/guard/cli.rb:110:in `start'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `inv
oke_command'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
> [#B530D13781CB] c:/Ruby200/lib/ruby/gems/2.0.0/gems/guard-1.7.0/bin/guard:6:in `<top (required)>'
> [#B530D13781CB] c:/Ruby200/bin/guard:23:in `load'
> [#B530D13781CB] c:/Ruby200/bin/guard:23:in `<main>'
14:57:29 - INFO - Guard::LiveReload has just been fired
[1] guard(main)>  Guard is now watching at 'l:/www/'

Any clue why it doesn't work?

EDIT#1:
The problem is in guard/livereload/reactor.rb, at line 1, require 'em-websocket'.
If I remove that line the error vanish.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.