Error trying to set environment variable with balena-cli

Hi all,

I’m trying to view / set an env var with balena-cli for OpenBalena.

balena envs --application myApp

I get

BalenaRequestError: Request error: Internal Server Error

Additional information may be available in debug mode. Prefix the command
line with DEBUG=1, i.e.:  DEBUG=1 balena ...
If you need help, don't hesitate in contacting our support forums at
https://forums.balena.io

For bug reports or feature requests, have a look at the GitHub issues or
create a new one at: https://github.com/balena-io/balena-cli/issues/

Is this currently supported?

Thanks!

Alex

Hey @ajlennon, can you run the request as this, for more debug information?

DEBUG=1 balena envs --application myApp

What version of openBalena are you running? Other than this the rest of the system works normally?

Here’s the output

ajlennon@ajlennon-VirtualBox:~/git/does-rpi3-dash$ DEBUG=1 balena envs --application myApp
BalenaRequestError: Request error: Internal Server Error
    at /usr/lib/node_modules/balena-cli/node_modules/balena-request/build/request.js:197:17
    at tryCatcher (/usr/lib/node_modules/balena-cli/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/usr/lib/node_modules/balena-cli/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/usr/lib/node_modules/balena-cli/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/usr/lib/node_modules/balena-cli/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/usr/lib/node_modules/balena-cli/node_modules/bluebird/js/release/promise.js:694:18)
    at _drainQueueStep (/usr/lib/node_modules/balena-cli/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/usr/lib/node_modules/balena-cli/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/usr/lib/node_modules/balena-cli/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues (/usr/lib/node_modules/balena-cli/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)

If you need help, don't hesitate in contacting our support forums at
https://forums.balena.io

For bug reports or feature requests, have a look at the GitHub issues or
create a new one at: https://github.com/balena-io/balena-cli/issues/

Looks like the hash of OpenBalena is #35ab5300e66f66df1c4dc960c47ac899a3993d53

Yes other than this all seems to be working pretty well :slight_smile:

Hello @ajlennon, see this thread for a solution using the API directly. TLDR; there is some dissonance in how env vars are handled between open source and cloud API v5 because the cloud API has some additional functionality that allows it to translate a request and match the model that didn’t make it in openBalena (yet). The next openBalena release will include a fix for this issue, but until then using the API directly is the workaround.

1 Like

Thanks for that @dfunckt!

Hi,
Which balena-cli & open-balena-api versions are you using?
Can you try whether open-balena-api v0.17.0 fixes the issue for you?

It looks like I’m running…


export OPENBALENA_API_VERSION_TAG=v0.11.8
export OPENBALENA_DB_VERSION_TAG=v2.0.3
export OPENBALENA_REGISTRY_VERSION_TAG=v2.5.0
export OPENBALENA_S3_VERSION_TAG=v2.5.0
export OPENBALENA_VPN_VERSION_TAG=v8.10.0

Will try to update

It looks to me like the API is still at this in the OpenBalena repo. How do I go about changing the API version I’m using (and will it break things I’m currently doing?)

Thanks,

Alex

Alex,

As you have identified, the current openBalena release is using the v0.11.8 version. We pinned them like this so that we could more easily identify which versions people would have just from the openBalena version; in this case v1.0.1

To update the API manually, edit the versions file to use v0.17.0 and then run the following command: dc pull && dc stop && dc rm && dc up -d. This will stop and remove all your containers (but not their volumes) and recreate them. You shouldn’t lose any data, but still it would be best to do a backup/snapshot before doing this.

1 Like

Lovely thanks @richbayliss. You guys are great!

ajlennon@ajlennon-VirtualBox:~/imx-yocto-bsp/build$ balena env add TESTKEY testvalue --application myApp
ajlennon@ajlennon-VirtualBox:~/imx-yocto-bsp/build$ balena envs --application myApp
ID NAME    VALUE
6  TESTKEY testvalue