Livereload option not working on Windows 10

Hi there,

I have a fresh install of Ruby2.7.0 and Jekyll following Jekyll tutorial (first part via RubyInstaller). I’m working on Visual Code Studio to create my blog on Github Pages using Jekyll static generator.

When I do a bundle exec jekyll serve it works fine. But when I add the option --livereload I get errors each first save of a file.

So, when starting the server :

bundle exec jekyll serve --trace --livereload
Configuration file: C:/Github/myrepo2/_config.yml
 Theme Config file: C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-theme-chirpy-3.2.2/_config.yml
            Source: C:/Github/myrepo2
       Destination: C:/Github/myrepo2/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
                    done in 6.728 seconds.
 Auto-regeneration: enabled for 'C:/Github/myrepo2'
LiveReload address: http://127.0.0.1:35729
    Server address: http://127.0.0.1:4000/myrepo2/
  Server running... press ctrl-c to stop.

And when saving a file after modification to see the update on my browser :

      Regenerating: 1 file(s) changed at 2021-03-14 07:08:47
                    _posts/2021-02-25-welcome.md
        LiveReload: Browser connected
#<Thread:0x00000000082ea6f0 C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve/live_reload_reactor.rb:41 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        7: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve/live_reload_reactor.rb:44:in `block in start'   
        6: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/eventmachine.rb:196:in `run'
        5: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:144:in `run_machine'
        4: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:547:in `run'
        3: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:547:in `loop'
        2: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:553:in `block in run'
        1: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:595:in `crank_selectables'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:595:in `select': An operation was attempted on something that is not a socket. (Errno::ENOTSOCK)
        7: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve/live_reload_reactor.rb:44:in `block in start'   
        6: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/eventmachine.rb:196:in `run'
        5: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:144:in `run_machine'
        4: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:562:in `run'
        3: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:559:in `ensure in run'
        2: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:559:in `each'
        1: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:559:in `block in run'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:559:in `close': Bad file descriptor (Errno::EBADF)  
Traceback (most recent call last):
        7: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve/live_reload_reactor.rb:44:in `block in start'   
        6: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/eventmachine.rb:196:in `run'
        5: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:144:in `run_machine'
        4: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:547:in `run'
        3: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:547:in `loop'
        2: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:553:in `block in run'
        1: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:595:in `crank_selectables'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:595:in `select': An operation was attempted on something that is not a socket. (Errno::ENOTSOCK)
        7: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve/live_reload_reactor.rb:44:in `block in start'   
        6: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/eventmachine.rb:196:in `run'
        5: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:144:in `run_machine'
        4: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:562:in `run'
        3: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:559:in `ensure in run'
        2: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:559:in `each'
        1: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:559:in `block in run'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:559:in `close': Bad file descriptor (Errno::EBADF)  

Can someone support me on getting this working ?

I does work on win 10, I use it.

Try doing gem list in the console and see if you have wdm installed. I have wdm 0.1.1.

Here is the list of gem

gem list

*** LOCAL GEMS ***

activesupport (6.0.3.5)
addressable (2.7.0)
benchmark (default: 0.1.0)
bigdecimal (default: 2.0.0)
bundler (2.2.14, default: 2.1.4)
cgi (default: 0.1.0)
coffee-script (2.4.1)
coffee-script-source (1.11.1)
colorator (1.1.0)
commonmarker (0.17.13)
concurrent-ruby (1.1.8)
csv (default: 3.1.2)
date (default: 3.0.0)
dbm (default: 1.1.0)
delegate (default: 0.1.0)
did_you_mean (default: 1.4.0)
dnsruby (1.61.5)
em-websocket (0.5.2)
etc (default: 1.1.0)
ethon (0.12.0)
eventmachine (1.2.7 x64-mingw32)
execjs (2.7.0)
faraday (1.3.0)
faraday-net_http (1.0.1)
fcntl (default: 1.0.0)
ffi (1.15.0 x64-mingw32)
fiddle (default: 1.0.0)
fileutils (default: 1.4.1)
forwardable (default: 1.3.1)
forwardable-extended (2.6.0)
gdbm (default: 2.1.0)
gemoji (3.0.1)
getoptlong (default: 0.1.0)
github-pages (212)
github-pages-health-check (1.17.0)
html-pipeline (2.14.0)
html-proofer (3.18.8)
http_parser.rb (0.6.0)
i18n (1.8.9, 0.9.5)
io-console (default: 0.5.6)
ipaddr (default: 1.2.2)
irb (default: 1.2.6)
jekyll (4.2.0, 3.9.0)
jekyll-archives (2.2.1)
jekyll-avatar (0.7.0)
jekyll-coffeescript (1.1.1)
jekyll-commonmark (1.3.1)
jekyll-commonmark-ghpages (0.1.6)
jekyll-default-layout (0.1.4)
jekyll-feed (0.15.1)
jekyll-gist (1.5.0)
jekyll-github-metadata (2.13.0)
jekyll-mentions (1.6.0)
jekyll-optional-front-matter (0.3.2)
jekyll-paginate (1.1.0)
jekyll-readme-index (0.3.0)
jekyll-redirect-from (0.16.0)
jekyll-relative-links (0.6.1)
jekyll-remote-theme (0.4.2)
jekyll-sass-converter (2.1.0, 1.5.2)
jekyll-seo-tag (2.7.1)
jekyll-sitemap (1.4.0)
jekyll-swiss (1.0.0)
jekyll-theme-architect (0.1.1)
jekyll-theme-cayman (0.1.1)
jekyll-theme-chirpy (3.2.2)
jekyll-theme-dinky (0.1.1)
jekyll-theme-hacker (0.1.2)
jekyll-theme-leap-day (0.1.1)
jekyll-theme-merlot (0.1.1)
jekyll-theme-midnight (0.1.1)
jekyll-theme-minimal (0.1.1)
jekyll-theme-modernist (0.1.1)
jekyll-theme-primer (0.5.4)
jekyll-theme-slate (0.1.1)
jekyll-theme-tactile (0.1.1)
jekyll-theme-time-machine (0.1.1)
jekyll-titles-from-headings (0.5.3)
jekyll-watch (2.2.1)
jemoji (0.12.0)
json (default: 2.3.0)
kramdown (2.3.0)
kramdown-parser-gfm (1.1.0)
liquid (4.0.3)
listen (3.4.1)
logger (default: 1.4.2)
matrix (default: 0.2.0)
mercenary (0.4.0, 0.3.6)
minima (2.5.1)
minitest (5.14.4, 5.13.0)
multipart-post (2.1.1)
mutex_m (default: 0.1.0)
net-pop (default: 0.1.0)
net-smtp (default: 0.1.0)
net-telnet (0.2.0)
nokogiri (1.11.2 x64-mingw32, 1.11.1 x64-mingw32)
nokogumbo (2.0.4)
observer (default: 0.1.0)
octokit (4.20.0)
open3 (default: 0.1.0)
openssl (default: 2.1.2)
ostruct (default: 0.2.0)
parallel (1.20.1)
pathutil (0.16.2)
power_assert (1.1.7)
prime (default: 0.1.1)
pstore (default: 0.1.0)
psych (default: 3.1.0)
public_suffix (4.0.6)
racc (1.5.2, default: 1.4.16)
rainbow (3.0.0)
rake (13.0.1)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
rdoc (default: 6.2.1)
readline (default: 0.0.2)
reline (default: 0.1.5)
rexml (3.2.4, default: 3.2.3)
rouge (3.26.0)
rss (default: 0.2.8)
ruby-enum (0.9.0)
ruby2_keywords (0.0.4)
rubyzip (2.3.0)
safe_yaml (1.0.5)
sass (3.7.4)
sass-listen (4.0.0)
sassc (2.4.0 x64-mingw32)
sawyer (0.8.2)
sdbm (default: 1.0.0)
simpleidn (0.2.1)
singleton (default: 0.1.0)
stringio (default: 0.1.0)
strscan (default: 1.0.3)
terminal-table (2.0.0, 1.8.0)
test-unit (3.3.4)
thread_safe (0.3.6)
timeout (default: 0.1.0)
tracer (default: 0.1.0)
typhoeus (1.4.0)
tzinfo (1.2.9)
tzinfo-data (1.2021.1)
unf (0.1.4)
unf_ext (0.0.7.7 x64-mingw32)
unicode-display_width (1.7.0)
uri (default: 0.10.0)
wdm (0.1.1)
webrick (default: 1.6.0)
xmlrpc (0.3.0)
yaml (default: 0.1.0)
yell (2.2.2)
zeitwerk (2.4.2)
zlib (default: 1.1.0)

This wdm 0.1.1 installed (almost at the end of the list)
And on my Gemfile, I already have this gem 'wdm', '~> 0.1.1', :install_if => Gem.win_platform?

googled that and found this which seems the same?

though not sure what the issue/solution is.

What are you using for the console? powershell? normal command prompt? linux shell thing? I use the command prompt and powershell with no problems - via VS code.

Thank you for the link.
I have already read it and not found a solution with it. From what I understood he was using an old version of Ruby, and by applying the new one it have solved the issue.

Also, I forgot to specified that to have the livereload option working I have applied this patch

Before this patch, livereload option was stopping while generating the server.

I’m using the terminal of VS Code and it’s automatically selecting the language. I saw PowerShell while writting the command, then “cmd” and finally Ruby.

In case this may help others, I successfully worked around the issue by launching a PowerShell window with admin rights, along with editing one file in ruby’s native libs, and it worked. Before, I tried to use the Ruby interpreter and the win Git Bash, none worked. I have a clean Ruby 2.7 install on Windows 10.

/EDIT: ah no, in fact only the first build works, but then the livereload fails, same error.

1 Like

Finally I’ve found an alternative, simply use in a PowerShell:

jekyll serve --watch

This worked whereas livereload always failed (even after uninstalling eventmanager and reinstalling it). It’s not like a livereload but it’s better than nothing.

@lrq3000, as you say, the watch command serves a different purpose.

  • Watch - Jekyll will rebuild the site on a file change.
  • Livereload - refresh browser on rebuild.

The watch command is also implied. So adding --watch does nothing. You can turn off the default with --no-watch.

Hi @Irq3000, I have exactly the same issue than you have. When I use jekyll serve --watch it doesn’t have the automatic reload of the page, it this normal?

Cheers

did you try jekyll serve --livereload or shorter jekyll s -l -o

-l is livereload
-0 is open it in a new browser window

I don’t think jekyll s by itself includes the reload of the browser - it will rebuild the site but I don’t think it will reload the browser.

I use win 10, works great for me in VSC terminal or CMD or PS.

No it doesn’t autoreload the page, you have to hit F5 to refresh everytime you make a change, but at least it automatically rebuild in the background.

@rdyar I tested all commands with livereload, they do not work, the livereload functionality is broken on my Windows 10 machine for some reason (and I’m not a Ruby coder, I started afresh), the same errors as stated above appear for me.

1 Like

if you do gem list what do you get for eventmachine?

mine is just eventmachine (1.2.7)

above I see the op has eventmachine (1.2.7 x64-mingw32)

I don’t understand what x64-mingw32 means, but maybe it is a problem? the op’s post has eventmachine errors.

do you get an error? can you post it?

Thank you @Irq3000, I’ll work like this then