Closed jenniupdates closed 7 months ago
Hi @jenniupdates,
From the provided error logs:
188 | /codebuild/output/tmp/script.sh: /codebuild/output/src1872811563/src/api_helpers/pre-api-helpers.sh: /bin/bash^M: bad interpreter: No such file or directory
There appears to be an extra carriage return character ^M
at the end of the failing interpreter path, i.e. /bin/bash^M
.
Can you check that the shebang header #!/bin/bash
in your pre-api-helpers script does not have this carriage return character?
It does have the #!/bin/bash
.
What should I replace it with or should I remove it?
#!/bin/bash
tells the system what interpreter to use, so keep the string itself, but ensure there is no carriage return character following it.
OHH okay I realised it was using CRLF because I was running on a Windows, switched it back to LF and the CodePipeline finally works, thank you!
AFT Version: 1.10.3 Terraform Version & Provider Versions
terraform version
terraform providers
Bug Description This is the error that I see in the global customisation CodeBuild for one of my account's CodePipeline.
/codebuild/output/tmp/script.sh: /codebuild/output/src1872811563/src/api_helpers/pre-api-helpers.sh: /bin/bash^M: bad interpreter: No such file or directory
Previously, when I ran the global customisations via invoke_customisation step function a month ago, I did not face this issue.To Reproduce Steps to reproduce the behavior:
Expected behavior It is suppose to succeed and echo "Executing Pre-API Helpers" or echo "Executing Post-API Helpers" according to the CodeBuild stage.
Related Logs 166 | [Container] 2023/11/20 06:20:46.038078 Phase complete: INSTALL State: SUCCEEDED 167 | [Container] 2023/11/20 06:20:46.038092 Phase context status code: Message: 168 | [Container] 2023/11/20 06:20:46.083943 Entering phase PRE_BUILD 169 | [Container] 2023/11/20 06:20:46.084875 Running command source $DEFAULT_PATH/api-helpers-venv/bin/activate 170 | 171 | [Container] 2023/11/20 06:20:46.091793 Running command export AWS_PROFILE=aft-target 172 | 173 | [Container] 2023/11/20 06:20:46.097911 Running command ls $DEFAULT_PATH 174 | README.md 175 | aft-venv 176 | api-helpers-venv 177 | api_helpers 178 | aws-aft-core-framework 179 | execution-input-sample.txt 180 | terraform 181 | 182 | [Container] 2023/11/20 06:20:46.107345 Running command ls $DEFAULT_PATH/api_helpers 183 | post-api-helpers.sh 184 | pre-api-helpers.sh 185 | python 186 | 187 | [Container] 2023/11/20 06:20:46.114707 Running command $DEFAULT_PATH/api_helpers/pre-api-helpers.sh 188 | /codebuild/output/tmp/script.sh: /codebuild/output/src1872811563/src/api_helpers/pre-api-helpers.sh: /bin/bash^M: bad interpreter: No such file or directory 189 | 190 | [Container] 2023/11/20 06:20:46.121156 Command did not exit successfully $DEFAULT_PATH/api_helpers/pre-api-helpers.sh exit status 126 191 | [Container] 2023/11/20 06:20:46.126628 Phase complete: PRE_BUILD State: FAILED_WITH_CONTINUE 192 | [Container] 2023/11/20 06:20:46.126646 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: $DEFAULT_PATH/api_helpers/pre-api-helpers.sh. Reason: exit status 126
Additional context When I invoked the step functions a month ago, I did not face this issue and it successfully ran the .sh scripts and echoed the correct statements. However, when I invoked it this week, it keeps stating that /bin/bash^M: bad interpreter: No such file or directory, even when I specifically
ls
to show that the directory and files exist. I read on stackoverflow that rather than missing directory/file issue, it could be the interpreter issue. Hence, I have also included the .sh script below for further elaboration:Why am I facing this error and how do I resolve this issue such that the CodeBuild would run correctly (perhaps without using dos2unix)? Thanks alot in advance.