17

Running the otherwise working command:

jekyll serve --watch

inside Vagrant is not leading to regeneration of the files unless I restart the jekyll server. I am editing on Windows. Is this a problem with Jekyll running inside Vagrant or is there some configuration that I need to do to make this work? I even tried using foreman with the following Procfile configuration but with the same result

web: jekyll serve --watch
Raunaq
  • 1,853
  • 1
  • 14
  • 19
  • What version of jekyll are you using? How are you installing Ruby (rvm, rbenv, distro package, etc.), and are you installing jekyll from gh-pages/bundle install, or as a manual `gem install jekyll`? – lunistorvalds Nov 07 '13 at 08:13
  • 1
    To the readers out there, by the time of writing (24/05/2014), @egezer gives a better answer than the accepted one to this question. – Hbas May 24 '14 at 17:55
  • Would you mind switching the accepted answer? @egezer's answer now actually answers the question. – Conan Sep 22 '14 at 15:16

5 Answers5

26

It's implemented in the latest pre release (jekyll 2.0.0.alpha.3 by the time of writing).

You should use --force_polling option to get benefit of it.

Try running the jekyll server like this:

jekyll serve --watch --force_polling
Erdem Gezer
  • 3,142
  • 2
  • 22
  • 16
  • 1
    This now works in the latest stable version (jekyll-2.0.3 by the time of writing). Thanks! – Hbas May 24 '14 at 17:47
  • jekyll build --watch isn't working for me... so I tried your solution instead and it works! :) Thanks! – Woppi Oct 26 '14 at 06:54
  • Hmmm.. Tried this and it looked like it was going to work. The jekyll console said it was Regenerating 1 file that I modified, but only the first time. And the changes were not reflected in the browser. – Neil Neyman Apr 29 '16 at 13:39
4

My guess, based on nothing more than my own experience of this issue is that you are running your jekyll site in the /vagrant folder which vagrant maps/syncs back to the host os.

These mapped or synchronised folders are using some kind of crazy filesystem driver (basically a type of network share) and the file watch features don't work on them.

This SO question shows the same symptom.

(You will see what I mean of you run your jekyll site outside `/vagrant' like in the home folder. Make a change (using nano) and you will see the Regeneration triggering)

Community
  • 1
  • 1
Pieter Breed
  • 5,579
  • 5
  • 44
  • 60
  • Yes, but putting it outside of the /vagrant directory kind of defeats the purpose of using Vagrant. I'm personally using it to isolate the build box (vm) from my daily machine, but I still want to take advantage of the convenience of editors of my host machine. Plus, to make it even more frustrating, this used to work. Then I updated VirtualBox. :( – janosrusiczki Feb 17 '14 at 18:16
  • Personally I'm starting to think that something like a docker container with jekyll in it is the (future) way to go for this type of separation. The host-OS restrictions are a little constricting though. – Pieter Breed Feb 18 '14 at 06:39
  • I'm experiencing this with `jeykill`'s repo in Windows file system but trying to run the site in Mac OS localhost. Parallels Desktop is messing things up for sure. – Leniel Maccaferri May 15 '14 at 18:23
3

What provider are you using? I was able to get it to work on Windows 8 using Virtual Box as a provider and Ubuntu 12.04 as a guest OS. I had to use version 1.2.1 and not the latest version however.

When I use the latest Jekyll version (1.4.2), watch does not work as expected (it doesn't notice the file change and does not rebuild). It does work when I edit them on the guest OS though (it does notice the file change and will rebuild).

Version 1.2.1 works regardless of where the files are edited from (Guest OS or Host OS).

To revert back to version 1.2.1 I ran the following commands:

gem uninstall jekyll
gem install jekyll -v 1.2.1

Note: The jekyll site is running from the vagrant directory

Jake Alves
  • 31
  • 2
  • Just a comment to say that Jake's solution works. To anyone else who comes across this post: if you use Github Pages be aware that github-pages depends on Jekyll 1.4.3, so by downgrading you do open yourself up to inconsistencies between your build environment and theirs. [The bug report](https://github.com/jekyll/jekyll/issues/1808) indicates the issue is with Jekyll's [Listen dependency](https://github.com/guard/guard/pull/555) who appear to be in the process of fixing it. – Andy Jones Feb 19 '14 at 19:33
  • Excellent answer Jake! This solved the problem OP is describing. – Hans Kristian Mar 02 '14 at 14:22
  • By the time of writing, in the latest stable version (jekyll-2.0.3), @egezer answer solves the problem the OP is describing – Hbas May 24 '14 at 17:48
1

In vagrant, just add --force_polling, then jekyll will watch almost all files except "_config.yml"

jekyll serve --force_polling

When you change the other files except for "_config.yml", you will see the regeneration.

But if you are changing "_config.yml" it will not trigger the regeneration.

Are you excepting the regeneration when you are changing "_config.yml"?

Nick
  • 41
  • 4
-1

My guess (without knowing the details) is that you need to be running headless, as in:

jekyll serve -w --detach

as mentioned in the jekyll documentation. If it's not that, then describe the issue in more detail, as I asked about in the comment. Also, are you using any type of provisioner in Vagrant, e.g. shell, chef, ansible, etc.?