Exclude from watch

I have a folder that I am trying, unsuccessfully, to exclude from the watch.

This seems very similar to this unresolved SO question from a year ago.

My _config.yml:

  - Gemfile
  - Gemfile.lock
  - __vendor # <-- exclude this

My dir structure

    dir2_simlink # points to dir1

jekyll serve

        ** ERROR: directory is already being watched! **

        Directory: .../site/__vendor/dir1
        is already being watched through: .../site/__vendor/dir2_simlink

Any ideas? Its very weird. (and __vendor IS excluded from the built _site - but it’s just not excluded from the watch.)

no idea about why Jekyll is doing that but you could use Gulp and browsersync and get live reloading, and part of that would be better control of what triggers the rebuild. I use Gulp to do the watch part, then it triggers Jekyll build.

cons: I think it is a little slower, can be complicated to set up if you are not familiar with it.

I guess something is wrong with your configuration. Here is my experiment with a setup similar to yours but using jekyll serve --verbose to peek behind the scenes.

And if I change anything in __vendor or _vendor Jekyll (jekyll-watch actually) does ignore any changes in these locations as expected…

Hope that helps.

Ok - it’s probably something with the simlinks, which I didn’t fully describe in my example. Maybe for efficiency the watch process watches the parent dir or something, which could explain it. Thanks for your help. I’ll close it since you’re right - it’s probably on my end.

Happy to help! Oh, I did miss the part about symlinks - let me try the other experiment with symlinks. My gut feeling is that since symlinks underneath __vendor folder, they should be ignored as well but we will see…

Can you also share the script you used to create symlink?

UPD: I did setup just like yours is and can repro the very same error in the console 100%. Just like in your configuration, I created vendor/dir1 and vendor/dir2 (symlink to dir1):

I dig further thru the codebase of jekyll-watch and listen gems and here is what I have found. The reason why the error message appears is because one of the listen gem components, record.rb, in _fast_build_dir method, indexing all the children items without taking into account the exclusion list and therefore prints out the error message.

Good news however, locations configured in _config.yml actually are excluded from the list of those being watched despite of the error. So, it is not a critical error per se - your Jekyll instance should remain fully functional.

The error message however a bit annoying and very confusing. I guess I have a clue how to fix it in the original code base…

UPD: Have forked the repository of listen gem (this is what jekyll-watch uses) and added some tests for your case to catch the gem red-handed of not handling the case properly… Believe it or not, the behavior is not triggered…

I’m still trying to wrap my head around how the gem is doing its work and doesn’t trigger the error code path. :confused:

Will try again on the weekend as the time permits…

Phew, have got some good progress and have found a solution to the issue, though the glitch still has to be fixed in the source code to make it bulletproof. :smile:

Here is the way how it DOES work (eq. way you can solve the issue). First, you need to setup a symbolic link between folder vendor/a and vendor/b using ln -s command and this is the visual log of how that would look like (TERMINAL tab):

Notice where b link points to… /Users/pabloduo/Documents/Github/avocado/docs/vendor/a, this is a fully-qualified path to the source folder. And if you launch bundle exec jekyll serve --verbose with this setup - you should see no error message in the output… This is how it looks like:

Enjoy! :fireworks:

Now, there is another interesting part of the issue… How would you reproduce the problem? It turns out there is a slight, but very important nuisance - path to your source directory when you create a symbolic link :wink:

Lets re-create linked folders structure again, this time NOT using fully-qualified path the source folder, like this:

Notice now, how symbolic link b points to a. Launching Jekyll again with bundle exec jekyll --verbose yields something interesting :smile:

Yay, riddle solved! :tada:

The summary is, for now use fully-qualified symbolic links between ignored folders in Jekyll and in the meantime I will try to send a pull request to listen gem to address the issue in full.

Well done, @pabloduo! I hadn’t thought to try fully qualified paths - that makes a lot of sense.

My pleasure! :slight_smile: