Symlinks flattened in AWS CodeDeploy bundle


#1

I’m running Node builds on CircleCI, and then deploying the code to AWS with CodeDeploy. There are some necessary symlinks in the project. The symlinks exist and behave properly in the CirceCI container, but it seems that when when CircleCI prepares a bundle to upload to S3, it “flattens” those symlinks, saving the the target of the symlink instead of preserving the symlink.

How can this behavior be changed?


#2

As reference, we use symlinks for executables to mirror the convention that npm. npm creates symlinks to executables inside modules modules in the node_modules/.bin folder (https://docs.npmjs.com/files/folders#executables). We put symlinks to all of our executables in a bin folder, and many of those links resolve to the symlink in the node_modules/.bin folder.

When those symlinks are flattened, the executables no longer work, because almost all of them use relative requires to pull in files.


#3

we use symlinks for executables to mirror the convention that npm

I’m not super familiar to node and npm, but is this really a convention? Adding node_modules/.bin to $PATH seems better approach in general to me.

Do you have some references to this practice besides https://docs.npmjs.com/files/folders#executables ?


#4

Ya, convention probably isn’t the right word; we’re more just mirroring what npm does when it creates symlinks in node_modules/.bin

There are a few reasons we using symlinks instead of modifying $PATH:

  • We don’t need all the executables inside node_modules/.bin
  • We want as few steps as possible in setting up a dev environment
  • We have other non-npm executables, and want all executables required for the application to live in the same location

Either way, though, the symlink flattening is an issue, because running npm install installs symlinks in node_modules/.bin (e.g., browserify -> ../browserify/bin/cmd.js, gulp -> ../gulp/bin/gulp.js), and those executables no longer work when the symlinks are flattened (because of relative requires).


#5

The symlinks are flatten when we zip your app into a bundle. The fix seems to be easy: just change the code to preserve symlink. However, I’m not sure about what will be affected by the change. I’ll look more and give you update.

AFAIK, the only workaround is not using the CodeDeploy integration and using aws cli to do the deployment.


#6

I’m experiencing the same issue here. It would be nice if CircleCI offered zip options when using CodeDeploy


#7

I face the same issue. Could CircleCI set the saving symlink option of zip?
And what status is this issue?


#8