Setting an ENV variable via balena-cli

I am trying to set up some variables through a shell script and I have noticed that it appears impossible to set a variable with a double- or single-quote inside.

For example, one would expect the following to work:

balena env add RESIN_HOST_CONFIG_dtparam "\"i2c_arm=on\",\"spi=on\",\"audio=off\"" --application ${APP_NAME} --config

I have tried all manner of combinations, but the parser within the balenaCloud seems to strip everything out.

Any suggestions or amazing tricks? I have checked out the source and cannot find a way yet.

Hi. Can you try like this:

balena env add RESIN_HOST_CONFIG_dtparam “i2c_arm=on,spi=on,audio=off” --application ${APP_NAME} --config

@floion - thanks, that is what can be used most of the time.

However, we have a couple of different dtoverlay settings that are for different modules and need to be on their own separate lines. This is done fine if set through the balenaCloud UI, but not when set from the balena-cli.

More info on the quotes within ENVs can be found here:
https://www.balena.io/docs/reference/OS/advanced/#setting-device-tree-overlays-dtoverlay-and-parameters-dtparam

In a nutshell, as detailed in the tech note, a comma-separated list of quote-enclosed values will be split into several lines. That’s what we need.

Indeed, I’d expect

balena env add RESIN_HOST_CONFIG_dtparam ‘“i2c_arm=on”,“spi=on”,“audio=off”’ --application ${APP_NAME} --config

to be how this should work but it doesn’t.
We’ll look into this and get back to you.

1 Like