Destination as sub-directory causes infinite loop on auto-regeneration #1184

Closed
frontendbeast opened this Issue Jun 6, 2013 · 10 comments

Comments

Projects
None yet
6 participants

Hi,

I'm having trouble setting the destination to a subdirectory, and running with auto-generation enabled.

jekyll serve --watch --port 8080

It works until I save a file that I've edited, when it regenerates the saved file which then triggers the entire site to update ad infinitum. My _config.yml looks like this:

source: ./
destination: _app/_site
exclude: ['_app']

Is there something I'm missing here with the config, or is this a bug? Cheers!

Darren

bash

Owner

parkr commented Jun 6, 2013

Bollocks. We fixed the problem produced by specifying a dir other than _site in the root ($CWD) but this was a case it doesn't cover. Thanks!

Owner

parkr commented Jul 9, 2013

This is tricky. When determining the globs to watch, it:

1. Fetches all the dirs in the source

>> Dir["*"].select { |x| File.directory?(x) }
=> ["_app", "_layouts", "_posts", "_site", "css", "images"]

2.Filters out several variations of destination

>> dirs -= [destination] # -= ["./_app/_site"]
=> ["_app", "_layouts", "_posts", "_site", "css", "images"]
>> dirs -= [File.expand_path(destination)] # -= ["/Users/parker/code/jekyll/tsite/_app/_site"]
=> ["_app", "_layouts", "_posts", "css", "images"]
>> dirs -= [File.basename(destination)] # -= ["_site"]
=> ["_app", "_layouts", "_posts", "css", "images"]

3. Maps to globs

>> dirs = dirs.map { |x| "#{x}/**/*" }
=> ["_app/**/*", "_layouts/**/*", "_posts/**/*", "css/**/*", "images/**/*"]

You can tell that in 2 it isn't filtering that stuff out properly.

@mattr- I think we need to flesh out _app/**/* into sub-globs and exclude the dir in which the destination lies.

Owner

mattr- commented Jul 11, 2013

I agree.

vonavi commented Mar 2, 2014

I see that my issue #1870 duplicates this one. But I pointed out the exact reason of the infinite loop on auto-regeneration.

Yeah, @vonavi is correct. Essentially there are a few cases that allow watch regeneration to work and some that don't.

Works:

  • Have no destination: value in _config.yml (uses the default absolute URL of _site inside the directory)
  • destination: /Users/ryanseys/mysite/_site in config.yml (using an absolute URL, even inside the directory)
  • destination: ../_site in config.yml (using an relative URL that is strictly outside the repo)

Does not work:

  • destination: _site in config.yml (using any relative URL inside the main directory) [this is effectively the same as the default config, but there's a bug specified by #1870 that addresses why this doesn't work]

Hope this helps users encountering this bug to implement a workaround depending on whether they want their build inside the main directory or not. I'm not knowledgeable enough with the code to implement a fix but @vonavi + #1870 should be a good start for someone who can! 😄

Edit: Sorry, web dev here. When I say "URL" I mean the directory names.

So basically, how to fix: Convert all destination names in config file into absolute destinations, even if specified as relative ones. File.expand_path might be a good start.

vonavi commented Apr 18, 2014

I use the following lines in _config.yml as a temporary workaround for the issue:

source:      ./
destination: ./public

Interesting tactic! Didn't think of that! 💃

@parkr parkr modified the milestones: 2.1, 2.0 May 5, 2014

Owner

parkr commented Jun 16, 2014

Does #2459 solve this?

@parkr parkr modified the milestones: 2.2, 2.1 Jun 16, 2014

@parkr parkr referenced this issue in jekyll/jekyll-watch Jul 31, 2014

Closed

Ensure Ignores Dest Dir #4

Owner

parkr commented Jul 31, 2014

We've released 2.2 and this still sucks. Moving over to jekyll-watch repo.

@parkr parkr closed this Jul 31, 2014

@jekyllbot jekyllbot locked and limited conversation to collaborators Feb 27, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.