[Lldb-commits] [lldb] [lldb] Fix misleading error message when re-importing command script (PR #207141)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 2 01:58:30 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Cyrus Ding (dingcyrus)
<details>
<summary>Changes</summary>
When running "command script import" a second time, the error message suggested using --overwrite, but that flag only exists on "command script add", not on "command script import". This was confusing because the user has no way to pass --overwrite through the import command.
The new message explicitly states that --overwrite applies to "command script add" and presents the settings alternative as a clear, standalone option:
Before:
user command "foo" already exists and force replace was not set
by --overwrite or 'settings set interpreter.require-overwrite false'
After:
user command "foo" already exists. To allow overwriting, pass
--overwrite to 'command script add' or run 'settings set
interpreter.require-overwrite false'
Fixes #<!-- -->206508
---
Full diff: https://github.com/llvm/llvm-project/pull/207141.diff
2 Files Affected:
- (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+3-3)
- (modified) lldb/test/API/commands/command/script/TestCommandScript.py (+4-3)
``````````diff
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 9887d24112c20..b28f56464cc40 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1363,9 +1363,9 @@ Status CommandInterpreter::AddUserCommand(llvm::StringRef name,
if (UserCommandExists(name)) {
if (!can_replace) {
result = Status::FromErrorStringWithFormatv(
- "user command \"{0}\" already exists and force replace was not set "
- "by --overwrite or 'settings set interpreter.require-overwrite "
- "false'",
+ "user command \"{0}\" already exists. To allow overwriting, "
+ "pass --overwrite to 'command script add' or run 'settings set "
+ "interpreter.require-overwrite false'",
name);
return result;
}
diff --git a/lldb/test/API/commands/command/script/TestCommandScript.py b/lldb/test/API/commands/command/script/TestCommandScript.py
index eb1584c64c90d..64abdc04c6352 100644
--- a/lldb/test/API/commands/command/script/TestCommandScript.py
+++ b/lldb/test/API/commands/command/script/TestCommandScript.py
@@ -166,9 +166,10 @@ def cleanup():
"command script add my_command --class welcome.TargetnameCommand",
substrs=[
(
- 'user command "my_command" already exists and force replace was'
- " not set by --overwrite or 'settings set"
- " interpreter.require-overwrite false'"
+ 'user command "my_command" already exists. To allow'
+ " overwriting, pass --overwrite to 'command script add'"
+ " or run 'settings set interpreter.require-overwrite"
+ " false'"
),
],
error=True,
``````````
</details>
https://github.com/llvm/llvm-project/pull/207141
More information about the lldb-commits
mailing list