jekyll/jekyll

Jekyll cannot locate any files in _includes

realchrisolin opened this issue · 23 comments

  • I believe this to be a bug, not a question about using Jekyll.
  • I updated to the latest Jekyll (or) if on GitHub Pages to the latest github-pages
  • I ran jekyll doctor to check my configuration
  • I read the CONTRIBUTION file at https://jekyllrb.com/docs/contributing/
  • I am on (or have tested on) Other GNU/Linux
  • I was trying to build.

My Reproduction Steps

See my follow up comment for more info.

I ran into this bug after copying the theme files from a custom remote theme into the local repository and updating _config.yml to no longer use jekyll-remote-theme, then trying to serve the site locally. Console output is below and I think the issue is fairly straightforward.

(personal) [pty2] ~/mysite (branch:master*) » bundle exec jekyll serve                                                                                                                                 1 ↵
Configuration file: /home/colin/mysite/_config.yml
            Source: /home/colin/mysite
       Destination: /home/colin/mysite/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
  Liquid Exception: Could not locate the included file 'disqus_comments.html' in any of ["/home/colin/mysite/_includes", "/home/colin/.gem/ruby/2.3.0/gems/jekyll-theme-primer-0.5.2/_includes"]. Ensure it exists in one of those directories and, if it is a symlink, does not point outside your site source. in /_layouts/post.html
jekyll 3.6.2 | Error:  Could not locate the included file 'disqus_comments.html' in any of ["/home/colin/mysite/_includes", "/home/colin/.gem/ruby/2.3.0/gems/jekyll-theme-primer-0.5.2/_includes"]. Ensure it exists in one of those directories and, if it is a symlink, does not point outside your site source.
(personal) [pty2] ~/mysite (branch:master*) » ll /home/colin/mysite/_includes                                                                                                                   1 ↵
total 18K
-rwxr-xr-x+ 1 colin None  705 Jan 24 21:20 disqus_comments.html
-rwxr-xr-x+ 1 colin None  915 Jan 24 21:20 footer.html
-rwxr-xr-x+ 1 colin None  568 Jan 24 21:20 google-analytics.html
-rwxr-xr-x+ 1 colin None  504 Jan 24 21:20 head.html
-rwxr-xr-x+ 1 colin None 1.7K Jan 24 21:20 header.html
-rwxr-xr-x+ 1 colin None 3.4K Jan 24 21:20 social.html

As you can see, disqus_comments.html clearly exists in the directory Jekyll is looking for it in. I run into the same issue with the other includes files if I remove the tag that is trying to load disqus_comments.html. There are no symlinks used here. The command I used to copy the theme files into mysite was cp -R _includes _layouts _sass assets ../mysite from a local directory with the remote theme files cloned into it.

Additionally, if I git reset all the changes to _config.yml, remove everything I copied over, and go back to using the remote theme, this issue stops occurring.

The Output I Wanted

A successful build

Additional troubleshooting info

(personal) [pty2] ~/mysite (branch:master*) » bundle exec jekyll doctor
Configuration file: /home/colin/mysite/_config.yml
  Your test results are in. Everything looks fine.

@realchrisolin Your reproduction steps should be clear enough for anyone coming across this ticket to walkthrough to reproducing this bug..
Currently, its not clear:

  • what theme you copied from..
  • what your current layouts are..
  • if you're using both theme: in config and loading external theme files at source

Please update your OP in the similar fashion..

  1. Create a new jekyll site
  2. Copy remote-theme files (from [theme-name]) to source directory
  3. Remove theme: and remote_theme: settings from config file.
  4. Run jekyll serve or jekyll build

Everything else better fits under the ### What I got and ### Other observations headings

Your reproduction steps should be clear enough for anyone coming across this ticket to walkthrough to reproducing this bug..

That wasn't my intention. Investigating the error that is contrary to reality is.

Nonetheless, I'm closing this as testing this in a new Jekyll project doesn't yield the same error until I copy over the Gemfile in the original project I encountered this issue in, which suggests it's an issue with my project and not a bug in Jekyll.

After further troubleshooting, I'm reopening this. It's easily reproducible.

1). Clone https://github.com/jekyll/minima
2). Create a new Jekyll project. jekyll new testsite
3). cd into the newly created minima directory and cp -R _includes _layouts _sass assets ../testsite
4). cd into testsite/ and edit _config.yml. Remove the theme: minima line and add the jekyll-seo-tag plugin.
5). bundle update && bundle exec jekyll serve

The only potential caveat is that I'm using github-pages/jekyll 3.6.2, which require another step to add to the project's Gemfile. It's entirely possible this has been fixed in jekyll 3.7

EDIT: That caveat was spot on. This issue occurs after adding github-pages to the project Gemfile during step 4:

group :jekyll_plugins do
    gem "github-pages", ">=173"
    gem "jekyll-feed", "~> 0.6"
end

If you remove the github-pages gem and run step 5, the issue no longer occurs.

instead of copying via cp -R, try doing a manual copy-paste (select the concerned directories from Minima clone > copy > move file explorer into test-site > paste)

The file operations are exactly the same between using cp -R or using a GUI file manager. This is an easily reproducible bug, not user error. Please take the time to comprehend the information I've included here and act accordingly.

/cc @jekyll/build

Attaching Gemfile.lock between working and broken environments.
Gemfile.lock.broken.log
Gemfile.lock.working.log

Not reproduced with latest jekyll and github-pages gem.

I beg to differ. I consistently reproduced it with the latest github-pages gem hours ago.

Not reproduced on Mac OS 10.13 with the latest github-pages gem.

Since there seems to be some confusion on how to reproduce this issue, I've recorded the following video. If there's reason to believe this is an environment issue, I can spin up the necessary EC2 instances and replicate it in different environments to establish that there is an easily reproducible bug at play here.

https://youtu.be/l_XvuxeoWZE

What if you remove or comment the gem "jekyll" line when you add gem "github-pages" to the jekyll-plugins group in the Gemfile?

Throws the same error. Two observations I want to point out:

  • When I remove gem "github-pages" with the gem "jekyll" line, the error isn't thrown.
  • When I add gem "github-pages" with or without the gem "jekyll" line, the error is thrown.

That isn't to suggest the issue is caused by "github-pages", but maybe one of its dependencies? I attached the Gemfile.lock snapshots a couple comments ago to help narrow down what those dependencies are/which dependency might be causing this.

$ git clone https://github.com/jekyll/minima
$ jekyll new testsite
$ cd minima
$ cp -R _includes _layouts _sass assets ../testsite
$ cd ../testsite
$ vi _config.yml # add jekyll-seo-tag and remove theme
$ bundle update
$ bundle exec jekyll build

No problems.

$ curl https://github.com/jekyll/jekyll/files/1664812/Gemfile.lock.broken.log > Gemfile.lock
$ bundle install
$ bundle exec jekyll build

No problems.

            Source: /home/colin/mysite
       Destination: /home/colin/mysite/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
  Liquid Exception: Could not locate the included file 'disqus_comments.html' in any of ["/home/colin/mysite/_includes", "/home/colin/.gem/ruby/2.3.0/gems/jekyll-theme-primer-0.5.2/_includes"]. Ensure it exists in one of those directories and, if it is a symlink, does not point outside your site source. in /_layouts/post.html

In your error report, Jekyll claims to be looking for disqus_comments.html in /home/colin/mysite/_includes, which is where it should be, and where it is (relative to site source) when I am testing.

Can you provide a minimal example that reproduces this issue, that doesn't clone any themes and doesn't rely on github-pages, but just includes as few files as possible to trigger the problem? Otherwise, it seems this is not a Jekyll bug.

Can you provide a minimal example that reproduces this issue, that doesn't clone any themes and doesn't rely on github-pages

I can't. This doesn't happen when the github-pages gem isn't added to the project Gemfile. If I should file this bug against the github-pages repo, please let me know.

Since none of us are able to reproduce this at our end.., (I tried to reproduce this just like your video, using Jekyll 3.6.0, 3.6.2, 3.7.0, github-pages 175.. no error..) I'd definitely recommend filing an issue elsewhere..

Because of the mention of jekyll-theme-primer, I suspect this might have something to do with GitHub pages automatically setting a theme. The weird thing is that it cannot be reproduced if a theme is explicitly set in config.yml, and the file exists in _includes/ anyway.

Since I cannot reproduce the issue using the Gemfile.lock that you provided, it really seems like it is something specific to your environment.

At the end of the day, if this can't be reproduced and does not exist using vanilla Jekyll, I'm not sure there is much we can do.

Point of contention, I am using vanilla Jekyll when reproducing this. There's nothing different about my environment that would make the cause an environment issue, least none that I can think of. My experience with Jekyll started four days ago and I've set up my environment exactly as detailed on jekyllrb.org Maybe I'll find the time to reproduce this in different environments in the coming days and we can reconsider whether or not this is an issue with Jekyll then. Seconded on the "weird thing" though. It's why I opened this issue in the first place because I was completely stumped that it can't find _includes files via the absolute path when they definitely exist. In the meantime, I'll continue using the remote theme to work around this issue in my Jekyll site. Thanks for taking the time to look into this.

At the minimum, there's enough information here for anyone else that may be experiencing this issue to find it from searching around the internet for others reporting it and confirm it's not just me 🤞

Point of contention, I am using vanilla Jekyll when reproducing this. There's nothing different about my environment that would make the cause an environment issue, least none that I can think of.

GitHub Pages injects other stuff into Jekyll. I am using the term “vanilla Jekyll” to differentiate from GitHub Pages, that’s all. You might consider opening an issue over there, being sure to point out that the issue only occurs when using the pages-gem

My experience with Jekyll started four days ago

I’m really sorry about all of this. I remember when I started using Jekyll and ran into several roadblocks. I wish there were something more I could do.

Out of curiosity, what OS and Ruby version are you using?

I’m really sorry about all of this. I remember when I started using Jekyll and ran into several roadblocks. I wish there were something more I could do.

No worries, it's not too discouraging. I started out by keeping the custom theme I'm using in a separate repository and didn't run into this issue until I tried moving everything into the site. It's annoying, but easily worked around with jekyll-remote-theme. If anything, I'd love to know why it can't find a file that clearly exists in the absolute path it's being looked for (that is what made me think it's an issue with Jekyll over github-pages)

Out of curiosity, what OS and Ruby version are you using?

The answer to the latter half of that question depends on how semantical you are.

(personal) [pty10] ~  » ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-cygwin]
(personal) [pty10] ~  » uname -a
CYGWIN_NT-10.0 colin 2.9.0(0.318/5/3) 2017-09-12 10:18 x86_64 Cygwin

I think it has something to do with github-pages having a default theme..
so you removing theme: minima automatically activates theme: jekyll-theme-primer and conflicts with the remote-theme: setting..

On an unrelated note, here's what I do to test a site with a theme called in from an external yet local repo..
(I'm on Windows..)

Test Site Path: C:\Projects\Test Site
Local Jekyll Repo Path: C:\Projects\jekyll
Local Theme Repo Path: C:\Projects\minima

# Gemfile in Test Site

gem "jekyll", :path => File.expand_path("../jekyll", __dir__)
gem "minima", :path => File.expand_path("../minima", __dir__)

Now I just need to use Git to use various versions of Jekyll or Minima as I prefer, without having to constantly bundle update..

Thanks! In tandem with a _config_dev.yml file and adjusting the bundle exec command as needed, I adopted that way of defining the theme gem in Gemfile to test theme changes locally before pushing them out to the remote theme repository production environments are pulling it in from.