Bug: Windows deploys broken because CRLF not converted to LF for bash/shell scripts
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Description:
I use Windows. I found that when pulling down the ```https://github.com/awslabs/aws-lambda-web-adapter``` repo, the LF characters are changed to CRLF (which is default git behaviour on Windows). This caused a problem with ```.sh``` files, since SAM build/deploy does not change CRLF back to LF, and the CRLF causes ```.sh``` scripts to fail. The same issue also occurs for ```bootstrap``` files.
This impacts all Windows users unless they take extra steps to convert CRLF to LF. It adds friction to the getting started experience, and is hard to diagnose/fix for Windows users who are not familiar with Linux.
Instead, this should 'just work', without Windows users having to think about it or do anything. I.e. SAM should convert the CRLF to LF as required.
See https://github.com/awslabs/aws-lambda-web-adapter/pull/369 for more info. That PR is a workaround for that repo only; the better fix is for SAM to convert CRLF to LF on Windows, fixing the issue for all repos.
### Steps to reproduce:
1. Use a Windows client
2. Sync https://github.com/awslabs/aws-lambda-web-adapter/ to your local machine
3. Navigate to the ```./examples/nodejs-zip``` folder
4. Run ```sam build --use-container``` followed by ```sam deploy --guided```
5. Open the deployed application endpoint in your browser
### Observed result:
Build and deploy appear to work fine.
When you open the application endpoint in your browser, an 'Internal server error' is shown.
Examining the logs, you see the error ```/var/task/run.sh: /bin/bash^M: bad interpreter: No such file or directory```.
As per https://stackoverflow.com/questions/14219092/bash-script-bin-bashm-bad-interpreter-no-such-file-or-directory this error is caused by CRLF rather than LF in the ```run.sh``` script.
### Expected result:
The example should work (and it does work, if you convert the CRLF to LF using a hex editor before you build/deploy).
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Windows 10
```
{
"version": "1.108.0",
"system": {
"python": "3.11.7",
"os": "Windows-10-10.0.19044-SP0"
},
"additional_dependencies": {
"docker_engine": "20.10.8",
"aws_cdk": "Not available",
"terraform": "Not available"
},
"available_beta_feature_env_vars": [
"SAM_CLI_BETA_FEATURES",
"SAM_CLI_BETA_BUILD_PERFORMANCE",
"SAM_CLI_BETA_TERRAFORM_SUPPORT",
"SAM_CLI_BETA_RUST_CARGO_LAMBDA"
]
}
```
Contributor guide
Assessment
This issue has not been assessed yet.