yarn icon indicating copy to clipboard operation
yarn copied to clipboard

Cannot set config when exec `yarn config set` which key start with "-"

Open tweet opened this issue 5 years ago • 2 comments

When we set config from yarn cli, it'll show errors if the config key start with -. For example, yarn config get "--mutex", yarn config set "--mutex" "network"

If using single quote yarn config set '--mutex' "network", the result is still error in .yarnrc. "'mutex'" network

version

yarn 1.22.5

Expected

success Set "--mutex" to "network".

Actual

error Invalid subcommand. Try "set, get, delete, list, current" info Visit https://yarnpkg.com/en/docs/cli/config for documentation about this command.

tweet avatar Mar 12 '21 11:03 tweet

Yarn v1 uses commander for command line argument parsing, and unfortunately this seems like an issue with commander. Possibly one of:

https://github.com/tj/commander.js/issues/636 https://github.com/tj/commander.js/issues/801 https://github.com/tj/commander.js/issues/289 https://github.com/tj/commander.js/issues/250

rally25rs avatar Apr 02 '21 21:04 rally25rs

You need to separate it with a -- to indicate that you're not trying to use an option

yarn config set -- "--mutex" "network"
yarn config get -- "--mutex"

merceyz avatar Apr 02 '21 22:04 merceyz