aws / aws/aws-codedeploy-agent

Getting an "unbound variable" error in Bash scripts

Abierto
#274 3 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
337
Forks
195
Merge medio
10 h 54 min
PR fusionados (30 d)
4

Descripción

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
```

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con config/code_deploy/after_install.sh y el registro de ejecución de CodeDeploy AfterInstall; después, inspecciona cómo se invoca el script con set -euxo pipefail. Reproduce el comando en el entorno indicado de Amazon Linux 2, Ruby y RVM, y determina qué contexto de shell produce la variable no definida; se considera terminado cuando el script de deployment se ejecuta correctamente sin ese error.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
bash, ruby
Área
devops
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.