aws / aws/aws-codedeploy-agent

Getting an "unbound variable" error in Bash scripts

Aperta
#274 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
337
Fork
195
Merge medio
10h 54m
PR unite (30g)
4

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con config/code_deploy/after_install.sh e il log di esecuzione CodeDeploy AfterInstall, quindi esamina come viene invocato lo script con set -euxo pipefail. Riproduci il comando nell’ambiente Amazon Linux 2, Ruby e RVM indicato e determina quale contesto della shell produce la variabile non definita; il lavoro è completato quando lo script di deployment viene eseguito correttamente senza questo errore.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
bash, ruby
Ambito
devops
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.