Skip to content

Commit 3e1f704

Browse files
committed
Merge branch 'fix/tools_click_envvar_v4.4' into 'release/v4.4'
Tools: Improve idf.py error message when the argument value collides with the environment variable (v4.4) See merge request espressif/esp-idf!21886
2 parents dd2c7f8 + 1bac78f commit 3e1f704

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tools/idf.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,14 @@ def _help_and_exit():
559559
default = () if option.multiple else option.default
560560

561561
if global_value != default and local_value != default and global_value != local_value:
562-
raise FatalError(
563-
'Option "%s" provided for "%s" is already defined to a different value. '
564-
'This option can appear at most once in the command line.' % (key, task.name))
562+
if hasattr(option, 'envvar') and option.envvar and os.getenv(option.envvar) != default:
563+
msg = (f'This option cannot be set in command line if the {option.envvar} '
564+
'environment variable is set to a different value.')
565+
else:
566+
msg = 'This option can appear at most once in the command line.'
567+
568+
raise FatalError(f'Option "{key}" provided for "{task.name}" is already defined to '
569+
f'a different value. {msg}')
565570
if local_value != default:
566571
global_args[key] = local_value
567572

0 commit comments

Comments
 (0)