Skip to content


Stop DirectoryWatcher from watching the destination directory #862

merged 6 commits into from

2 participants

Jekyll member

@svnpenn noticed that the change in 7457cba didn't actually fix the problem it was meant to. The mix of absolute and relative paths in the method caused the issue. I believe my fix here works and I added a couple tests to ensure the method runs as intended.

@mattr-, any input on the tests would be awesome. I'm used to Rspec's "describe-context" mix so the "context-should" was a bit awkward for me. :)

parkr added some commits
@parkr parkr Renamed test under wrong name. b49bba9
@parkr parkr Fix bug where Command.globs didn't delete the destination directory.
There was often a mix between absolute and relative paths and in the
previous version, the destination argument was usually an absolute
path where the glob array (from Dir['*']) was a relative path.
@parkr parkr Using a test_dir helper method for tests. a0c0d98
@parkr parkr Rudimentary tests for Jekyll::Command d93faac
@parkr parkr Added directory_with_contents() to DRY up test code and ensure folder…
…s exist in TestCommand.
@parkr parkr merged commit 6c1a08c into master

1 check passed

Details default The Travis build passed
@parkr parkr deleted the fix-autogen-dest-prob branch
@parkr parkr added a commit that referenced this pull request
@parkr parkr Update history to reflect merge of #862. b3c3197

@parkr this is still happening with Jekyll beta using ruby 2.0.0 on Windows 7


@svnpenn I will post a screenshot in a minute. The weirdest thing is sometimes it works fine until you change a file then it starts regenerating the files over and over it never stops. What's crazy is if you only change one file it regenerates a hunk of files like 50-70 but all different amounts every regeneration every two seconds. After I post my screenshot you well see what I mean.
Then sometimes it just regenerates the same number of files (60) in a continuous loop.


@parkr @svnpenn when I run Jekyll beta latest with ruby 2.0.0 it gives me the following warning before executing any command.
DL is deprecated please use fiddle
I Have fiddle gem installed. That doesn't fix the warning.
Everything else seems to work perfectly Jekyll build and serve are working as expected. Just the --watch command is acting crazy and regenerating in an endless loop.
Do you think it has something to do with this run time warning?
Jekyll latest stable is working perfectly with ruby 2.0.0 on the same machine.


@svnpenn my bad :( I do want tohelp. I will post the full version numbers along with a screenshot as soon as I get home.


@svnpenn OK.

by Jekyll beta latest, I mean jekyll 1.0.0.beta1
by Jekyll stable latest I mean, Jekyll 0.12.1

I will refer to them in full from now on anyways just for clarity.

I am using jekyll 1.0.0.beta1 with Ruby 2.0.0 on Windows 7

If I run jekyll serve -w then it generates the site starts the server then gets stuck in a loop.

jekyll-1 0 1-beta-1-onstart

If I run jekyll build then it generates the site fine.

then I run jekyll serve -w and it generates the site starts the server and waits for changes.

jekyll-1 0 1-beta-1-afterbuild

But, Then If I make a change to any file it will regenerate that file then get stuck in the loop like

jekyll-1 0 1-beta-1-afterbuild-afterchange

The weird part is that it keeps regenerating a different number of files sometimes.

here is my _config.yml


and here is my local gem list for ruby 2.0.0 (in three parts there are no repetitions in any photo)




When I was using Jekyll 0.12.1 with Ruby 2.0.0 everything was working fine.

If I use Ruby 1.9.3 with Jekyll 0.l2.1 on the same project it works perfectly.

-- If I use jekyll 1.0.0.beta1 with Ruby 1.8.7 then it does the same thing as Ruby 2.0.0 except for no warning about: DL is deprecated please use Fiddle here is the output from Ruby 1.8.7 with jekyll 1.0.0.beta1

jekyll-1 0 1-beta-1-ruby-1 8 7

Another Thing. How are you supposed to exclude folders that are not in the root of the project?

in my _config.yml if I try to exclude the assets/sass like below

exclude: [assets/sass, mixture.json]

then it doesn't work and it generates the sass folder in _site

if I leave off the assets directory then it works as expected like:

exclude: [sass, mixture.json]

Then it excludes the sass folder inside assets/sass. This is what I am trying to achieve, yet this doesn't seem right.

Now If I have a folder named sass in the root of my project and a folder named sass at assets/sass it excludes them both. Neither of the sass folders are generated to _site on build.

If try to just exclude the assets/sass directory like below Jekyll ignores me and includes them both

exclude: [assets/sass, mixture.json]

I have also tried the following variations of the exclude

exclude: [assets/sass/, mixture.json]


exclude: ["assets/sass", "mixture.json"]


exclude: ["/assets/sass/", "mixture.json"]

the quotes didn't seem to make a difference. In the wiki it show the exclude with no quotes.

What is the correct way to exclude a directory that isn't in the root and keep the one that is in the root with the same name? It seems strange that if you specify a file or folder that Jekyll will exclude it from every directory that is in the root folder. Is this the expected behavior of exclude?

Am I missing something? Thanks for all your hard work guys I appreciate ya'll


@svnpenn ok I fixed the above here is the version copy and pasted from my shell

jekyll 1.0.0.beta1

@svnpenn you happy? can I be taken seriously now?

I am new to GitHub and would like to be helpful.


@svnpenn thanks for your help.

anyways I am installing jekyll 1.0.0.beta2 now I will see if the problem is fixed.


@svnpenn the re generation problem is fixed in jekyll 1.0.0.beta2
The exclude issue is still happening though. Perhaps I should move that to its own issue?
@parkr @svnpenn thanks for all your work on this project you guys :)

Jekyll member

@jwebcat If there is another problem, let's talk about that in a new issue :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 16, 2013
  1. @parkr

    Renamed test under wrong name.

    parkr committed
  2. @parkr

    Fix bug where Command.globs didn't delete the destination directory.

    parkr committed
    There was often a mix between absolute and relative paths and in the
    previous version, the destination argument was usually an absolute
    path where the glob array (from Dir['*']) was a relative path.
  3. @parkr
  4. @parkr
  5. @parkr
  6. @parkr
Showing with 53 additions and 4 deletions.
  1. +1 −1 features/site_configuration.feature
  2. +1 −1 lib/jekyll/command.rb
  3. +12 −2 test/helper.rb
  4. +39 −0 test/test_command.rb
2 features/site_configuration.feature
@@ -3,7 +3,7 @@ Feature: Site configuration
I want to be able to configure jekyll
In order to make setting up a site easier
- Scenario: Change destination directory
+ Scenario: Change source directory
Given I have a blank site in "_sourcedir"
And I have an "_sourcedir/index.html" file that contains "Changing source directory"
And I have a configuration file with "source" set to "_sourcedir"
2 lib/jekyll/command.rb
@@ -3,7 +3,7 @@ class Command
def self.globs(source, destination)
Dir.chdir(source) do
dirs = Dir['*'].select { |x| }
- dirs -= [destination]
+ dirs -= [destination, File.expand_path(destination), File.basename(destination)]
dirs = { |x| "#{x}/**/*" }
dirs += ['*']
14 test/helper.rb
@@ -28,17 +28,27 @@ class Test::Unit::TestCase
include RR::Adapters::TestUnit
def dest_dir(*subdirs)
- File.join(File.dirname(__FILE__), 'dest', *subdirs)
+ test_dir('dest', *subdirs)
def source_dir(*subdirs)
- File.join(File.dirname(__FILE__), 'source', *subdirs)
+ test_dir('source', *subdirs)
def clear_dest
+ def test_dir(*subdirs)
+ File.join(File.dirname(__FILE__), *subdirs)
+ end
+ def directory_with_contents(path)
+ FileUtils.rm_rf(path)
+ FileUtils.mkdir(path)
+"#{path}/index.html", "w"){ |f| f.write("I was previously generated.") }
+ end
def capture_stdout
$old_stdout = $stdout
$stdout =
39 test/test_command.rb
@@ -0,0 +1,39 @@
+require 'helper'
+class TestCommand < Test::Unit::TestCase
+ context "when calling .globs" do
+ context "when non-default dest & source dirs" do
+ setup do
+ @source = source_dir
+ @dest = dest_dir
+ directory_with_contents(@dest)
+ @globs = Command.globs(@source, @dest)
+ end
+ should "return an array without the destination dir" do
+ assert @globs.is_a?(Array)
+ assert !@globs.include?(@dest)
+ end
+ teardown do
+ clear_dest
+ end
+ end
+ context "when using default dest dir" do
+ setup do
+ @source = test_dir
+ @dest = test_dir('_site')
+ directory_with_contents(@dest)
+ @globs = Command.globs(@source, @dest)
+ end
+ should "return an array without the destination dir" do
+ assert @globs.is_a?(Array)
+ assert !@globs.include?(@dest)
+ @globs.each do |glob|
+ assert !glob.include?(File.basename(@dest))
+ end
+ end
+ teardown do
+ FileUtils.rm_r(@dest)
+ end
+ end
+ end
Something went wrong with that request. Please try again.