jekyll / jekyll

:globe_with_meridians: Jekyll is a blog-aware static site generator in Ruby

Home Page:https://jekyllrb.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to integrate Jekyll watch with Vagrant?

tonicospinelli opened this issue · comments

I created a VM with Vagrant to run jekyll server, when I edit the files inside VM it works, but when I edit in my workstation, the changes not applied.

How to do it work?

My Vagrantfile

The watch and detach flags cannot be used together. Remove detach and you should be good to go.

If you want to use Vagrant to run jekyll, you'll also have to use your VM to develop as well, unless you sync the site files between the your workstation and the VM with a shared folder, rsync, or some other mechanism.

@parkr and @mattr-

thanks for attention.

Because that "limit", I executed the command vagrant ssh -c 'cd /vagrant && jekyll build' in my workstation to see my updates

This version of jekyll works with watch inside Vagrant/VirtualBox:
gem uninstall jekyll
gem install jekyll -v 1.2.1

Use --watch with --force_polling to enable reload when files changes outside of Vagrant.

All versions of Jekyll should work great with --watch.

Yeah, but not inside VirtualBox (via Vagrant).

Vagrant doesn't work with auto regen? Is the sync feature too slow?

Well, Vagrant doesn't actually do the syncing, it is just a glorified configuration tool to set up and provision the virtual machines. I'm using it on my Mac with Oracle VirtualBox to run my Jekyll sites locally. Here is the documentation for VirtualBox shared folders.

sudo mount for the shared folder gives me the following information:

vagrant on /vagrant type vboxsf (uid=1000,gid=1000,rw)

My hunch tells me that vboxsf does not trigger a file stystem inotify event?! And that might be the reason that Jekyll is not picking up the change?

Jekyll is not alone on not picking up changes in synced files inside Vagrant/VirtualBox, a quick google search yields a dozen or more results on this for various tools. What I can't quite figure out is what changed in Jekyll 1.2.1, because this version picks up changes immediately and regenerates the site as it is supposed to?

The version of Listen is what would have changed. If you want the later features of Jekyll, try the --force-polling option when running build or serve with --watch

Thanks a million @parkr 👍 --force_polling works like a charm!