aws / aws/aws-codedeploy-agent

Getting an "unbound variable" error in Bash scripts

Open
#274 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
337
Forks
195
Avg merge
10h 54m
Merged PRs (30d)
4

Description

I'm getting a weird 'unbound variable' problem when I try to run my AfterInstall script. This same script works fine in Amazon Linux1 under the same environment (Ruby / RVM).

Environment:
- Amazon Linux2
- Ruby 2.5.8 (RVM)
- Latest CodeDeploy agent

This is the first part of my `config/code_deploy/after_install.sh` script. It seems to be choking on the `cd` command for some reason.
```
#!/bin/bash
set -euxo pipefail
export RAILS_ENV=$DEPLOYMENT_GROUP_NAME
cd /var/site/current
...
```

This is the error that I'm getting in CodeDeploy. I have no idea what 'unbound variable' it's trying to find.
```
LifecycleEvent - AfterInstall
Script - config/code_deploy/after_install.sh
[stderr]+ export RAILS_ENV=myenv
[stderr]+ RAILS_ENV=myenv
[stderr]+ cd /var/site/current
[stderr]+ __zsh_like_cd cd /var/site/current
[stderr]+ typeset __zsh_like_cd_hook
[stderr]+ builtin cd /var/site/current
[stderr]/opt/codedeploy-agent/deployment-root/5f156457-724d-48f6-8105-222222222222/d-11111111/deployment-archive/config/code_deploy/after_install.sh: chpwd_functions[@]: unbound variable
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.