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
3
  • 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? Nov 7, 2013 at 8: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, 2014 at 17:55
  • Would you mind switching the accepted answer? @egezer's answer now actually answers the question.
    – Conan
    Sep 22, 2014 at 15:16

5 Answers 5

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
3
  • 1
    This now works in the latest stable version (jekyll-2.0.3 by the time of writing). Thanks!
    – Hbas
    May 24, 2014 at 17:47
  • jekyll build --watch isn't working for me... so I tried your solution instead and it works! :) Thanks!
    – Woppi
    Oct 26, 2014 at 6: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. Apr 29, 2016 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)

3
  • 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. :( Feb 17, 2014 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. Feb 18, 2014 at 6: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. May 15, 2014 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

3
  • 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 indicates the issue is with Jekyll's Listen dependency who appear to be in the process of fixing it.
    – Andy Jones
    Feb 19, 2014 at 19:33
  • Excellent answer Jake! This solved the problem OP is describing. Mar 2, 2014 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, 2014 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"?

2
  • Could you please elaborate more your answer adding a little more description about the solution you provide?
    – abarisone
    Apr 13, 2016 at 14:47
  • Sorry for my poor english, nevertheless I have upgraded it.
    – Nick
    Apr 17, 2016 at 15:00
-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.?

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.