1

I'm trying to deploy laravel app to aws beanstalk, OS is Amazon Linux 2 AMI.

I've setup following files:

.ebextensions/01-deploy-script-permission.config

It contains below code:

container_commands:
    01-storage-link:
        command: 'sudo chmod +x .platform/hooks/postdeploy/post-deploy.sh'     

And

.platform\hooks\postdeploy/01-post-deploy.sh

It contains below code:

php artisan optimize:clear

Upon deploying it fails with following entry in eb-engine.log file

[ERROR] An error occurred during execution of command [app-deploy] - [RunAppDeployPostDeployHooks]. Stop running the command. Error: Command .platform/hooks/postdeploy/post-deploy.sh failed with error fork/exec .platform/hooks/postdeploy/post-deploy.sh: no such file or directory

TylerH
  • 20,799
  • 66
  • 75
  • 101
Ravikumar Sharma
  • 3,678
  • 5
  • 36
  • 59

2 Answers2

5

This answer is for users who are using Windows to deploy their files to elastic beanstalk.

I found this information after spending 6 precious hours. Probably not documented anywhere in official documentations

As per this link "https://forums.aws.amazon.com/thread.jspa?threadID=321653"

psss: most important that the file is saved with LF line separator. CRLF makes "no file or directory found"

So I used Visual Studio Code to convert CRLF to LF for files in .platform/hooks/postdeploy

At the bottom right of the screen in VS Code there is a little button that says “LF” or “CRLF”: Click that button and change it to your preference.

Kevin M. Mansour
  • 2,915
  • 6
  • 18
  • 35
Ravikumar Sharma
  • 3,678
  • 5
  • 36
  • 59
  • I run all my scripts through `dos2unix` as one of my first ebextensions steps, which takes care of this problem. Some of us develop on/deploy from Windows, and others use Macs. – Matt Aug 29 '22 at 16:54
  • 1
    Related, for maven users: https://stackoverflow.com/a/2162678/2751039 – Matt Aug 29 '22 at 17:03
0

I don't know for sure but I think you are running the command before the files are even created hence getting the following error.

A while ago I faced the same kind of problem where I wrote migration commands in .ebextension and it used to give me an error because my env file wasn't even created yet hence no DB connection is made so I was getting the error. Hope this will give you a direction. By the way, I resolved the problem by creating env then pushing these commands through the pipeline.

  • I had a different issue, it was related to line-ending: It is not document in AWS docs anywhere but found from community: https://stackoverflow.com/a/66047579/1550566 – Ravikumar Sharma Jun 17 '21 at 06:43