# Exporting array variables prevents values from being set locally on bionic

**URL:** <https://travis-ci.community/t/exporting-array-variables-prevents-values-from-being-set-locally-on-bionic/9954>\
**Category:** Linux\
**Created:** [September 20, 2020, 5:38pm UTC](https://travis-ci.community/t/exporting-array-variables-prevents-values-from-being-set-locally-on-bionic/9954 "2020-09-20T17:38:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkralphs](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/tkralphs/32/4133_2.png) [@tkralphs](https://travis-ci.community/u/tkralphs)\
**Post date:** [September 20, 2020, 5:38pm UTC](https://travis-ci.community/t/exporting-array-variables-prevents-values-from-being-set-locally-on-bionic/9954/1 "2020-09-20T17:38:09Z")

</div>

As part of a Travis build, I’m running a relatively simple bash script downloaded from [here](https://github.com/coin-or/coinbrew/blob/master/.ci/setup_environment.sh) and exporting several array variables. I have now realized that exporting array variables is not supported in bash, but the issue is that the exporting is also blocking the variables from being set locally for some reason. Although I `source` the script, the variables aren’t properly set. The whole setup works fine on xenial and MacOS (with recent bash downloaded from homebrew). I also checked that it works fine if I run the script locally in the same Docker container as the job is being run in on Travis (travisci/ci-ubuntu-1804:packer-1593521720-ca42795e). There seems to be something with the way Travis is wrapping these scripts when processing the configuration file that is causing this behavior. I know that I can simply not export the bash arrays, but am posting this for the benefit of others who may run into this and because it seems to be buggy behavior.

A recent build that demonstrates the behavior is [here](https://travis-ci.org/github/coin-or/Clp/builds/727571651) and the configuration is [here](https://github.com/coin-or/Clp/blob/ff5cdacd64253d42e4eed6fa824a9ce9a4353a76/.travis.yml). In the first job [here](https://travis-ci.org/github/coin-or/Clp/jobs/727571652) running on bionic, I set the value of the variable `COMMON_ARGS` (a bash array) in the script [here](https://travis-ci.org/github/coin-or/Clp/jobs/727571652#L798) like so:

```auto
export COMMON_ARGS=(--no-prompt --verbosity ${VERBOSITY:-2} --tests main --enable-relocatable)

```

Afterwards, I echo it’s value [here](https://travis-ci.org/github/coin-or/Clp/jobs/727571652#L806) (along with the values of some other variables) like so:

```auto
echo "${COMMON_ARGS[@]}" "${ADD_ARGS[@]}" "${DBG_ARGS[@]}"

```

but the variables whose values were just set are now empty.

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [September 21, 2020, 7:40am UTC](https://travis-ci.community/t/exporting-array-variables-prevents-values-from-being-set-locally-on-bionic/9954/2 "2020-09-21T07:40:24Z")

</div>

Hello @tkralphs,

It seems after a branch refactor this passes build, are you still having the same issue?

---

<div class="post-metadata">

**Author:** ![tkralphs](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/tkralphs/32/4133_2.png) [@tkralphs](https://travis-ci.community/u/tkralphs)\
**Post date:** [September 21, 2020, 3:04pm UTC](https://travis-ci.community/t/exporting-array-variables-prevents-values-from-being-set-locally-on-bionic/9954/3 "2020-09-21T15:04:07Z")

</div>

Hi @Montana, the build was never failing as a result of this issue, it just wasn’t building in the configuration I had specified because of the fact that the variables weren’t getting set properly. I have a workaround now, so I guess it’s not an issue for me, but I believe this is a bug and since it caused me a lot of headache before I figured out the workaround, I thought it would be useful to others to report it. It may also indicate some issue with the way Travis is processing the configuration file, which could have bigger implications, not sure. So for me, everything is currently OK.

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [September 22, 2020, 4:56am UTC](https://travis-ci.community/t/exporting-array-variables-prevents-values-from-being-set-locally-on-bionic/9954/4 "2020-09-22T04:56:04Z")

</div>

Hey @tkralphs,

Thanks for the update - if there’s anything else please post back and I’ll help you out!
