https://github.com/dingcyrus created 
https://github.com/llvm/llvm-project/pull/207141

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

>From 45c2032ddc6b7b5e967be75dcb1268f0c715d816 Mon Sep 17 00:00:00 2001
From: Chenguang Ding <[email protected]>
Date: Thu, 2 Jul 2026 15:40:07 +0800
Subject: [PATCH] [lldb] Fix misleading error message when re-importing command
 script

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
---
 lldb/source/Interpreter/CommandInterpreter.cpp             | 6 +++---
 lldb/test/API/commands/command/script/TestCommandScript.py | 7 ++++---
 2 files changed, 7 insertions(+), 6 deletions(-)

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,

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to