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:

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

Any news ? @floion

Hi, I just tried the following and it worked. Im on balena-cli version 11.18.0.

balena env add RESIN_HOST_CONFIG_dtparam '"i2c_arm=on","spi=on","audio=off"' --application ${SOME_APP}

What is the command you are using?

Hi again @mrrobot,

I wanted to follow up and see if you’ve had a chance to test balena-cli>=11.18.0? If so, can you provide a minimal example of what is still not working?