Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: livereload-ignore option doesn't work #9502

Open
wlabarron opened this issue Dec 13, 2023 · 2 comments · May be fixed by mslinn/jekyll#1 or #9570
Open

[Bug]: livereload-ignore option doesn't work #9502

wlabarron opened this issue Dec 13, 2023 · 2 comments · May be fixed by mslinn/jekyll#1 or #9570
Labels
has-pull-request Somebody suggested a solution to fix this issue

Comments

@wlabarron
Copy link

Operating System

macOS 14.1.2

Ruby Version

ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin23]

Jekyll Version

jekyll 4.3.2

GitHub Pages Version

No response

Expected Behavior

After specifying ^\.wrangler\/ in the livereload-ignore config parameter or the --livereload_ignore command line argument, files changing in the .wrangler directory should not trigger a live reload when running bundler exec jekyll serve --livereload.

Current Behavior

Files changing in the .wrangler directory trigger a live reload, and the verbose output shows that .wrangler is not making it to jekyll-watch for ignoring:

         Requiring: jekyll-watch
           Watcher: Ignoring (?-mix:^_config\.yml)
           Watcher: Ignoring (?-mix:^_site\/)
           Watcher: Ignoring (?-mix:^package\.json)
           Watcher: Ignoring (?-mix:^package\-lock\.json)
           Watcher: Ignoring (?-mix:^README\.md)
           Watcher: Ignoring (?-mix:^\.jekyll\-cache\/)
           Watcher: Ignoring (?-mix:^Gemfile)
           Watcher: Ignoring (?-mix:^Gemfile\.lock)
           Watcher: Ignoring (?-mix:^node_modules\/)
 Auto-regeneration: enabled for '[project path]'
LiveReload address: http://127.0.0.1:35729

Relevant log output

No response

Code Sample

No response

@wlabarron
Copy link
Author

This can be worked around by putting the path to ignore in the exclude config parameter, but will mean that path is also not considered when building the site.

@mslinn
Copy link

mslinn commented Mar 28, 2024

I encountered this bug on Windows 10 with Jekyll 4.3.3. I used this configuration setting in _config.yml:

livereload_ignore: [ '/assets/images/qrcodes/*' ]

When my generator writes files into /assets/images/qrcodes/, a reload is triggered. I need these files to be part of the site, so I cannot exclude them. Thus, the workaround suggested by @wlabarron is not an option.

The problem is the call on line 161 of lib/jekyll/commands/serve.rb to Jekyll.sanitized_path requires 2 arguments, but only one was supplied. Either this feature was never tested, or the method signature for Jekyll.sanitized_path had a breaking change that was not properly tested:

File.fnmatch(filter, Jekyll.sanitized_path(p.relative_path))

The comment and method signature are:

    # Public: Ensures the questionable path is prefixed with the base directory
    #         and prepends the questionable path with the base directory if false.
    #
    # base_directory - the directory with which to prefix the questionable path
    # questionable_path - the path we're unsure about, and want prefixed
    #
    # Returns the sanitized path.
    def sanitized_path(base_directory, questionable_path)

One easy way to fix this bug would be simply to avoid the call to Jekyll.sanitized_path.
This seems reasonable because I do not believe the call adds value.
Thus, we are left with:

File.fnmatch(filter, p.relative_path)

I tested this and it worked.

Incidentally, the Jekyll docs should mention that the contents of the livereload_ignore array are governed by the rules for the first argument of File.fnmatch.

mslinn added a commit to mslinn/jekyll that referenced this issue Mar 28, 2024
Makes `livereload_ignore` finally work properly.
This was referenced Mar 28, 2024
@jekyllbot jekyllbot added the has-pull-request Somebody suggested a solution to fix this issue label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-pull-request Somebody suggested a solution to fix this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants