Jekyll --watch command not working in shared folder (nfs) Mac host machine using Virtual box Ubuntu guest machine

StackOverflow https://stackoverflow.com/questions/21124077

Question

I have a Virtual Box VM running Ubuntu. I have configured an nsf share (when I say I, someone helped me so I am not very clued up on NFS shares) so that I can work on my Mac host machine and use it's tools such as Sublime Text.

However, when I run the following command: jekyll serve --watch

When I make code changes the site is not automatically regenerated. So currently I have to stop the server and run the command again.

EDIT:

Additionally it works fine if I create a jekyll site outside of the nfs share. Just a standard normal folder on the guest machine.

Was it helpful?

Solution

Then uninstall Jekyll v 1.4.2 and install Jekyll v 1.2.1

To do so run these commands,

gem uninstall jekyll
y
gem install jekyll -v 1.2.1

OTHER TIPS

There is no need to install an older version of jekyll - you need to use --force_polling. Explanation follows:

VirtualBox will not send inotify events for shared folders to the guest. This is intentional:

jekyll up to version 1.2.1 would poll directories for changes by default, but it has since changed the way it listens for modifications, apparently to use inotify events, which works better. This does break listening on shared folders though but the old behavior can be forced using the --force_polling option along with --watch when using build or serve:

jekyll serve --watch --force_polling

I found this out from a related issue on jekyll's repo:

update: I've now started using jekyll through VirtualBox myself and have found that there is a slight issue sometimes with jekyll watching files through a shared folder: it reads file modifications wrong, resulting in files that should be copied unmodified to the generated site being identical to their previous version except there's garbage carriage returns at the end (yes, even if the file format is set to unix line endings). To resolve this, you can use rsync to copy the files to the virtual hard drive and have jekyll watch that directory instead:

rsync -a --recursive --delete /source/directory/ /target/directory/inside/vm/

to keep it automated, you can turn the above into a script (or not) and use watch:

watch -n1 /path/to/rsync/script.sh

then just have jekyll watch the target directory and it works fine. If you do it this way, --force_polling shouldn't be necessary unless somehow your virtualized OS isn't using inotify events. I've left it as is and I haven't had any issues although clearly inotify events are a more elegant way of treating the problem.

Update to Latest version of Jekyll, or atleast to Jekyll v 1.2.1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top