Eleventy: Failure copying a directory to the output root

Created on 24 Mar 2020  Â·  6Comments  Â·  Source: 11ty/eleventy

Describe the bug
I have a directory with my favicon files.
I add a copy rule like:

eleventyConfig.addPassthroughCopy({ "favicon": "/" });

If I set the output path to a directory and include a trailing slash, like --output /var/www/blog.witchoflight.com/ then it fails to copy with:

> Having trouble copying './favicon'

`TemplatePassthroughManagerCopyError` was thrown
> Destination is not in the site output directory. Check your passthrough paths.

`TemplatePassthroughError` was thrown:
    TemplatePassthroughError: Destination is not in the site output directory. Check your passthrough paths.
        at TemplatePassthrough.copy (/home/git/blog.witchoflight.com/node_modules/@11ty/eleventy/src/TemplatePassthrough.js:77:7)
        at TemplatePassthrough.write (/home/git/blog.witchoflight.com/node_modules/@11ty/eleventy/src/TemplatePassthrough.js:99:21)
        at TemplatePassthroughManager.copyPath (/home/git/blog.witchoflight.com/node_modules/@11ty/eleventy/src/TemplatePassthroughManager.js:108:8)
        at TemplatePassthroughManager.copyAll (/home/git/blog.witchoflight.com/node_modules/@11ty/eleventy/src/TemplatePassthroughManager.js:144:26)
        at TemplateWriter.write (/home/git/blog.witchoflight.com/node_modules/@11ty/eleventy/src/TemplateWriter.js:159:26)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
        at async Eleventy.write (/home/git/blog.witchoflight.com/node_modules/@11ty/eleventy/src/Eleventy.js:659:13)
Unhandled rejection in promise ([object Promise]): (more in DEBUG output)

To Reproduce
Steps to reproduce the behavior:

  1. Add a passthrough copy rule that copies a directory into the root.
  2. Run a build with a path like --output path/ending/with/slash/.

Expected behavior
It should successfully build at the path without errors.

Environment:

  • OS and Version: Ubuntu 19.10
  • Eleventy Version: 0.10.0
bug

Most helpful comment

@lxg oof, I'm sorry 😢. That's actually how I got involved with eleventy — I couldn't stand that only one guy maintained the whole thing.

All 6 comments

This error seems to be caused in copy in TemplatePassthrough, it runs a string-based path inclusion:

    if (
      TemplatePath.stripLeadingDotSlash(dest).includes(
        TemplatePath.stripLeadingDotSlash(this.outputDir)
      )
    ) {

This fails if the outputDir has a trailing slash because the dest will be computed to not have on. This should probably use proper path inclusion instead of string inclusion.

@porglezomp Did you consider creating a PR? If not, I could do it, but I figure as you’ve already seem to have a solution in mind, you might as well implement it. :)

I think I was originally planning to but wasn't sure that to use for path computations—and now my job means I have to get approval to contribute to projects, so you implementing it would probably end up much faster.

@lxg are you still up for the PR? If not, I could probably do it, but I don't really get what the change would be.

Sorry, I don’t work with Eleventy anymore. I tried contributing in the past, but PRs and issue reports were ignored. I decided to dedicate my time to other projects.

@lxg oof, I'm sorry 😢. That's actually how I got involved with eleventy — I couldn't stand that only one guy maintained the whole thing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

veleek picture veleek  Â·  3Comments

ndaidong picture ndaidong  Â·  4Comments

michrome picture michrome  Â·  3Comments

aaronstezycki picture aaronstezycki  Â·  3Comments

zellwk picture zellwk  Â·  3Comments