Skip to content

balena env set fails when the environment variable value starts with hyphen #3113

Open

Description

@caracas009

Description

When using balena env set to create an environment variable whose value starts with hyphen (for example, -hello), the CLI fails before executing the command.

Instead of treating the quoted string as the value of the environment variable, the CLI reports it as a nonexistent flag.

Environment
balena-cli: 25.1.7
Platform: darwin-x64 (macOS)
Node.js: v24.16.0

Steps to reproduce
balena env set TEST "-hello"
--device <device_uuid>
--service <service_name>

Expected behavior

The environment variable TEST should be created with the value: -hello

Actual behavior

The command fails with:

Error: Nonexistent flag: -hello
See more help with --help

   See more help with --help
    at validateArgs (/usr/local/lib/balena-cli/node_modules/@oclif/core/lib/parser/validate.js:10:19)
    at validate (/usr/local/lib/balena-cli/node_modules/@oclif/core/lib/parser/validate.js:234:5)
    at Object.parse (/usr/local/lib/balena-cli/node_modules/@oclif/core/lib/parser/index.js:22:35)
    at async EnvSetCmd.parse (/usr/local/lib/balena-cli/node_modules/@oclif/core/lib/command.js:280:25)
    at async EnvSetCmd.run (/usr/local/lib/balena-cli/build/commands/env/set.js:10:50)
    at async EnvSetCmd._run (/usr/local/lib/balena-cli/node_modules/@oclif/core/lib/command.js:182:22)
    at async Config.runCommand (/usr/local/lib/balena-cli/node_modules/@oclif/core/lib/config/config.js:456:25)
    at async run (/usr/local/lib/balena-cli/node_modules/@oclif/core/lib/main.js:97:16)
    at async /usr/local/lib/balena-cli/build/app.js:84:13
    at async Promise.all (index 2)

Activity

  1. changed the title [-]`balena env set` fails when the environment variable value starts with hyphens[/-] [+]`balena env set` fails when the environment variable value starts with hyphen[/+] on Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions