ln command behaving mysteriously with Laravel Envoyer


April 2019


55 time


I have a laravel project deployed to AWS. Recently I gave a thought about using Envoyer for zero downtime deployment.

My project has an uploads directory where user uploads are added by code. Of course that's not added in git.

So when envoyer deploys code I have to symlink my uploads folder to the current directory. I have added a deploy script (After activate new release):

ln -s ~/<myproject>/uploads ~/<myproject>/current/uploads

When the envoyer deploys I get the symlinks at place but the dir is something like:

audio  images  uploads

While the actual directory is like:

audio images

(Note the above output is of ls command in uploads directory)

I don't understand why the symlink is having another dir named uploads and the images and audio folders are empty. Btw, the odd new uploads folder that is being created inside that uploads symlink is actually having proper structure. But that's not what I need, I need to have the audio and images folder with proper files in it.

What I have tried?

I ssh'd to the server and ran the same command as I added for envoyer and that is creating symlink properly. But to automate that I actually need to have that in Envoyer deployment hook.

Anyone having any idea? I guess deployment symlink hook should be a common practice in Envoyer.

1 answers


The problem was that I had an uploads folder already in the git. (This was added to preserve the directory structure with .gitignore files in each).

To tackle this I am just removing the directory before linking.