garden icon indicating copy to clipboard operation
garden copied to clipboard

"Attempted to copy non-file" when a symlink target is a folder

Open orarbel opened this issue 3 years ago • 8 comments

Bug

Building breaks when a module contains a symlink to a folder.

The offending line only checks if the target of a symlink is a file, but doesn't check if it's a folder.

https://github.com/garden-io/garden/blob/893e55b6e4932dda671509248ce2acf513eb8526/core/src/build-staging/helpers.ts#L68

Current Behavior

An error of "Attempted to copy non-file" is raised.

Expected behavior

The build will be successful.

Reproducible example

Projects that contain a symlink to a folder.

Suggested solution(s)

Add a condition that checks if the target is a folder and if so don't raise an error.

Additional context

Your environment

  • OS: macOS BigSur 11.3
  • How I'm running Kubernetes: Docker Desktop

garden version 0.12.21

orarbel avatar May 08 '21 13:05 orarbel

Thanks for the detailed report @orarbel. Should be a quick fix on our end.

eysi09 avatar May 11 '21 09:05 eysi09

@edvald, could you confirm that the suggestion makes sense? If that's the case I can fix it on my end.

eysi09 avatar May 11 '21 09:05 eysi09

Yeah I think that does make sense, but I wanna take a quick look to make sure. Lots of little devils in the details in this stuff .)

edvald avatar May 13 '21 13:05 edvald

All right, I'll assign this to you then. Feel free to re-assign.

eysi09 avatar May 18 '21 09:05 eysi09

This issue has been automatically marked as stale because it hasn't had any activity in 90 days. It will be closed in 14 days if no further activity occurs (e.g. changing labels, comments, commits, etc.). Please feel free to tag a maintainer and ask them to remove the label if you think it doesn't apply. Thank you for submitting this issue and helping make Garden a better product!

stale[bot] avatar Aug 17 '21 08:08 stale[bot]

hi there, any update on this? I found the same issue with one of our projects. We have some symlinks to directories and it fails when building the module.

Thanks.

jondeandres avatar Oct 12 '21 17:10 jondeandres

@jondeandres is this still a problem in 0.13?

vvagaytsev avatar Jun 19 '23 09:06 vvagaytsev

@vvagaytsev hey I can attest this is also a problem for me. In 0.13 this code is still checking only if it symlinks a file not a folder.

This would be fixed if the code was:

if (!sourceStats.isFile() && !sourceStats.isDirectory()) { 

abMatGit avatar Mar 20 '24 21:03 abMatGit