cli: Deploy does not follow symlinks

Describe the bug

netlify deploy does not follow symlinks out of the publish directory and misses files.

To Reproduce

cd out/
ln -s ../index.html out/
cd ..
netlify deploy

Configuration

[build]
base = "."
publish = "out/"
command = "wasm-pack build --target no-modules"

Expected behavior

index.html should be included in the deploy. It isn’t.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 8
  • Comments: 15 (8 by maintainers)

Most upvoted comments

This is an issue because Netlify’s auto-deploys do follow symlinks.

So this CLI bug leads to a discrepancy between auto-deploys and manual deploys via the CLI.

@tinfoil-knight, do you know if there are any plans to address this in the near future?

Tried out fast-glob locally. It has a followsymboliclinks option which actually does what I described above. It follows symlinks to individual files and files under linked directories.

Ah, I think I overcomplicated this. How are you suggesting to fix the filtering issue?

@erezrokah I was just saying that here:

https://github.com/netlify/cli/blob/dda5a499b9a8286484bf5559fd645761c374dbc9/src/utils/deploy/hasher-segments.js#L55

We can check if the file object is a symbolic link. Get the path to the linked file/directory (through fs.readlink). Then check if that path is actually a file or not. (fs.stat)

If the linked path is a file, we just don’t filter it out.


But now that I think about it more, there’s also the case for symlinks to directories which have files under them.

The files under these directories will need to be “walked” too which further complicates this issue. (We’d actually need to resolve the symlinks first in this case before any filtering happens)

@erezrokah Thanks, will do.