Skip to content

Commit e61ed1c

Browse files
authored
Remove the 'upgrade' message. (#1802)
The 'upgrade' message asks users to rerun bootstrap-vcpkg. We used to do this all over the place but have been slowly doing it less often. Unfortunately, even the places that were reasonable, were mostly inconsistent about applying it. In particular, emitting the upgrade message for things that require `git pull` is *incorrect*. Ever emitting the message in Visual Studio or one-liner deployments was always bogus. (The reason for this is because I'm context-izing `vcpkg fetch` and there are a lot of problematic upgrade cases in there) Audit results: * strings.cpp:380: Wrong, parse failure is not a tool upgrade fix. (Note however the only callers where visualstudio.cpp which was questionably ok) * strings.cpp:396: Ditto * binaryparagraph.cpp:251: Both cases are about corrupted installation databases and both are wrong. * binaryparagraph.cpp:261: Ditto * commands.build.cpp:438: Probably correct, new vcpkg.exe may learn about new cpu architecture. * commands.build.cpp:467: Probably correct, new vcpkg.exe may learn about new VS. * commands.build.cpp:1045: Probably correct, new vcpkg may learn about new known architectures. * commands.build.cpp:2147: Wrong, corrupted installation database. * commands.edit.cpp:171: Wrong, nonexistent port won't be fixed by bootstrap. * commands.format-manifest.cpp:59: This is just a bug in vcpkg and *probably* shouldn't be localized in the first place. It's a parse failure so it's wrong. * commands.integrate.cpp:658: Plausible, new integrates may be learned by new vcpkg.exe. * commands.package-info.cpp:47: Plausible, new vcpkg may have new package-info formats. But we don't emit the message for other unknown command line arguments so why is this one special? * commands.remove.cpp:184: Wrong, upgrading vcpkg.exe won't make this not be manifest mode. * commands.update.cpp:62: Ditto * dependencies.cpp:299: Wrong, missing feature won't change by rebootstrap * dependencies.cpp:860: Ditto * registries.cpp:865: Wrong, missing git sha in the registry won't change by rebootstrap * statusparagraph.cpp:86: Wrong, corrupted installation database. * tools.cpp:854: Wrong, missing tool entry won't change by rebootstrap * tools.cpp:1053: Plausible, new vcpkg.exe may learn new ways to find a tool from the system * vcpkglib.cpp:201: Wrong, corrupted database. * vcpkgpaths.cpp:86: Wrong, parse error. * vcpkgpaths.cpp:195: Wrong, bogus git SHA. Total: 6 correct/plausible, 16 wrong.
1 parent 71538f2 commit e61ed1c

22 files changed

+81
-172
lines changed

include/vcpkg/base/checks.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ namespace vcpkg::Checks
2828
[[noreturn]] void exit_success(const LineInfo& line_info);
2929

3030
// Display an error message to the user and exit the tool.
31-
[[noreturn]] void exit_with_message(const LineInfo& line_info, StringView error_message);
32-
[[noreturn]] void exit_with_message(const LineInfo& line_info, const LocalizedString&) = delete;
3331
[[noreturn]] void msg_exit_with_message(const LineInfo& line_info, const LocalizedString& error_message);
3432
template<VCPKG_DECL_MSG_TEMPLATE>
3533
[[noreturn]] void msg_exit_with_message(const LineInfo& line_info, VCPKG_DECL_MSG_ARGS)
@@ -55,33 +53,6 @@ namespace vcpkg::Checks
5553
}
5654
}
5755

58-
// Display a message indicating that vcpkg should be upgraded and exit.
59-
[[noreturn]] void exit_maybe_upgrade(const LineInfo& line_info);
60-
[[noreturn]] void exit_maybe_upgrade(const LineInfo& line_info, StringView error_message);
61-
[[noreturn]] void exit_maybe_upgrade(const LineInfo&, const LocalizedString&) = delete;
62-
[[noreturn]] void msg_exit_maybe_upgrade(const LineInfo& line_info, const LocalizedString& error_message);
63-
template<VCPKG_DECL_MSG_TEMPLATE>
64-
[[noreturn]] void msg_exit_maybe_upgrade(const LineInfo& line_info, VCPKG_DECL_MSG_ARGS)
65-
{
66-
msg_exit_maybe_upgrade(line_info, msg::format(VCPKG_EXPAND_MSG_ARGS));
67-
}
68-
69-
// Check the indicated condition and call exit_maybe_upgrade if it is false.
70-
void check_maybe_upgrade(const LineInfo& line_info, bool condition);
71-
void check_maybe_upgrade(const LineInfo& line_info, bool condition, StringView error_message);
72-
void check_maybe_upgrade(const LineInfo& line_info, bool condition, const LocalizedString&) = delete;
73-
void msg_check_maybe_upgrade(const LineInfo& line_info, bool condition, const LocalizedString& error_message);
74-
template<VCPKG_DECL_MSG_TEMPLATE>
75-
VCPKG_SAL_ANNOTATION(_Post_satisfies_(_Old_(expression)))
76-
void msg_check_maybe_upgrade(const LineInfo& line_info, bool expression, VCPKG_DECL_MSG_ARGS)
77-
{
78-
if (!expression)
79-
{
80-
// Only create the string if the expression is false
81-
msg_exit_maybe_upgrade(line_info, msg::format(VCPKG_EXPAND_MSG_ARGS));
82-
}
83-
}
84-
8556
[[noreturn]] inline void msg_exit_with_error(const LineInfo& line_info, const LocalizedString& message)
8657
{
8758
msg::write_unlocalized_text_to_stderr(Color::error, error_prefix().append_raw(message).append_raw('\n'));
@@ -94,5 +65,4 @@ namespace vcpkg::Checks
9465
error_prefix().append(VCPKG_EXPAND_MSG_ARGS).append_raw('\n'));
9566
Checks::exit_fail(line_info);
9667
}
97-
9868
}

include/vcpkg/base/message-data.inc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,6 @@ DECLARE_MESSAGE(
459459
"different architecture. This usually means toolchain information is incorrectly conveyed to the binaries' "
460460
"build system. To suppress this message, add set(VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK enabled)")
461461
DECLARE_MESSAGE(ChecksFailedCheck, (), "", "vcpkg has crashed; no additional details are available.")
462-
DECLARE_MESSAGE(ChecksUnreachableCode, (), "", "unreachable code was reached")
463-
DECLARE_MESSAGE(ChecksUpdateVcpkg, (), "", "updating vcpkg by rerunning bootstrap-vcpkg may resolve this failure.")
464462
DECLARE_MESSAGE(CiBaselineAllowUnexpectedPassingRequiresBaseline,
465463
(),
466464
"",

include/vcpkg/base/messages.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ namespace vcpkg
149149
inline constexpr StringLiteral MessagePrefix = "message: ";
150150
LocalizedString message_prefix();
151151
inline constexpr StringLiteral InfoPrefix = "info: ";
152-
LocalizedString info_prefix();
153152
inline constexpr StringLiteral NotePrefix = "note: ";
154-
LocalizedString note_prefix();
155153
inline constexpr StringLiteral WarningPrefix = "warning: ";
156154
LocalizedString warning_prefix();
157155
}

locales/messages.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,6 @@
294294
"CMakeUsingExportedLibs": "To use exported libraries in CMake projects, add {value} to your CMake command line.",
295295
"_CMakeUsingExportedLibs.comment": "{value} is a CMake command line switch of the form -DFOO=BAR",
296296
"ChecksFailedCheck": "vcpkg has crashed; no additional details are available.",
297-
"ChecksUnreachableCode": "unreachable code was reached",
298-
"ChecksUpdateVcpkg": "updating vcpkg by rerunning bootstrap-vcpkg may resolve this failure.",
299297
"CiBaselineAllowUnexpectedPassingRequiresBaseline": "--allow-unexpected-passing can only be used if a baseline is provided via --ci-baseline.",
300298
"CiBaselineDisallowedCascade": "REGRESSION: {spec} cascaded, but it is required to pass. ({path}).",
301299
"_CiBaselineDisallowedCascade.comment": "An example of {spec} is zlib:x64-windows. An example of {path} is /foo/bar.",

src/vcpkg/base/checks.cpp

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace vcpkg
6060
[[noreturn]] void Checks::unreachable(const LineInfo& line_info)
6161
{
6262
msg::write_unlocalized_text_to_stderr(
63-
Color::error, locale_invariant_lineinfo(line_info).append(msgChecksUnreachableCode).append_raw('\n'));
63+
Color::error, locale_invariant_lineinfo(line_info).append_raw(" unreachable code was reached\n"));
6464
#ifndef NDEBUG
6565
std::abort();
6666
#else
@@ -89,12 +89,6 @@ namespace vcpkg
8989

9090
[[noreturn]] void Checks::exit_success(const LineInfo& line_info) { exit_with_code(line_info, EXIT_SUCCESS); }
9191

92-
[[noreturn]] void Checks::exit_with_message(const LineInfo& line_info, StringView error_message)
93-
{
94-
msg::write_unlocalized_text(Color::error, error_message);
95-
msg::write_unlocalized_text(Color::error, "\n");
96-
exit_fail(line_info);
97-
}
9892
[[noreturn]] void Checks::msg_exit_with_message(const LineInfo& line_info, const LocalizedString& error_message)
9993
{
10094
msg::println(Color::error, error_message);
@@ -138,57 +132,4 @@ namespace vcpkg
138132
msg_exit_with_message(line_info, error_message);
139133
}
140134
}
141-
142-
static void display_upgrade_message()
143-
{
144-
msg::write_unlocalized_text_to_stderr(Color::error,
145-
note_prefix().append(msgChecksUpdateVcpkg).append_raw('\n'));
146-
}
147-
148-
[[noreturn]] void Checks::exit_maybe_upgrade(const LineInfo& line_info)
149-
{
150-
display_upgrade_message();
151-
exit_fail(line_info);
152-
}
153-
154-
[[noreturn]] void Checks::exit_maybe_upgrade(const LineInfo& line_info, StringView error_message)
155-
{
156-
msg::write_unlocalized_text_to_stderr(
157-
Color::error,
158-
LocalizedString::from_raw(error_message).append_raw('\n').append(msgChecksUpdateVcpkg).append_raw('\n'));
159-
exit_fail(line_info);
160-
}
161-
[[noreturn]] void Checks::msg_exit_maybe_upgrade(const LineInfo& line_info, const LocalizedString& error_message)
162-
{
163-
msg::write_unlocalized_text_to_stderr(Color::error, error_message);
164-
msg::write_unlocalized_text_to_stderr(Color::none, "\n");
165-
display_upgrade_message();
166-
exit_fail(line_info);
167-
}
168-
169-
void Checks::check_maybe_upgrade(const LineInfo& line_info, bool expression)
170-
{
171-
if (!expression)
172-
{
173-
exit_maybe_upgrade(line_info);
174-
}
175-
}
176-
177-
void Checks::check_maybe_upgrade(const LineInfo& line_info, bool expression, StringView error_message)
178-
{
179-
if (!expression)
180-
{
181-
exit_maybe_upgrade(line_info, error_message);
182-
}
183-
}
184-
185-
void Checks::msg_check_maybe_upgrade(const LineInfo& line_info,
186-
bool expression,
187-
const LocalizedString& error_message)
188-
{
189-
if (!expression)
190-
{
191-
msg_exit_maybe_upgrade(line_info, error_message);
192-
}
193-
}
194135
}

src/vcpkg/base/messages.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ namespace vcpkg
123123
LocalizedString error_prefix() { return LocalizedString::from_raw(ErrorPrefix); }
124124
LocalizedString internal_error_prefix() { return LocalizedString::from_raw(InternalErrorPrefix); }
125125
LocalizedString message_prefix() { return LocalizedString::from_raw(MessagePrefix); }
126-
LocalizedString info_prefix() { return LocalizedString::from_raw(InfoPrefix); }
127-
LocalizedString note_prefix() { return LocalizedString::from_raw(NotePrefix); }
128126
LocalizedString warning_prefix() { return LocalizedString::from_raw(WarningPrefix); }
129127
}
130128

src/vcpkg/base/strings.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -377,33 +377,34 @@ std::vector<StringView> Strings::find_all_enclosed(StringView input, StringView
377377
StringView Strings::find_exactly_one_enclosed(StringView input, StringView left_tag, StringView right_tag)
378378
{
379379
std::vector<StringView> result = find_all_enclosed(input, left_tag, right_tag);
380-
Checks::msg_check_maybe_upgrade(VCPKG_LINE_INFO,
381-
result.size() == 1,
382-
msgExpectedOneSetOfTags,
383-
msg::count = result.size(),
384-
msg::old_value = left_tag,
385-
msg::new_value = right_tag,
386-
msg::value = input);
387-
return result.front();
380+
if (result.size() == 1)
381+
{
382+
return result.front();
383+
}
384+
385+
Checks::msg_exit_with_message(VCPKG_LINE_INFO,
386+
msgExpectedOneSetOfTags,
387+
msg::count = result.size(),
388+
msg::old_value = left_tag,
389+
msg::new_value = right_tag,
390+
msg::value = input);
388391
}
389392

390393
Optional<StringView> Strings::find_at_most_one_enclosed(StringView input, StringView left_tag, StringView right_tag)
391394
{
392395
std::vector<StringView> result = find_all_enclosed(input, left_tag, right_tag);
393-
Checks::msg_check_maybe_upgrade(VCPKG_LINE_INFO,
394-
result.size() <= 1,
395-
msgExpectedAtMostOneSetOfTags,
396-
msg::count = result.size(),
397-
msg::old_value = left_tag,
398-
msg::new_value = right_tag,
399-
msg::value = input);
400-
401-
if (result.empty())
402-
{
403-
return nullopt;
396+
switch (result.size())
397+
{
398+
case 0: return nullopt;
399+
case 1: return result.front();
400+
default:
401+
Checks::msg_exit_with_message(VCPKG_LINE_INFO,
402+
msgExpectedAtMostOneSetOfTags,
403+
msg::count = result.size(),
404+
msg::old_value = left_tag,
405+
msg::new_value = right_tag,
406+
msg::value = input);
404407
}
405-
406-
return result.front();
407408
}
408409

409410
bool vcpkg::Strings::contains_any_ignoring_c_comments(const std::string& source, View<vcpkg_searcher> to_find)

src/vcpkg/binaryparagraph.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ namespace vcpkg
248248
Paragraphs::parse_single_paragraph(StringView{out_str}.substr(initial_end), sanity_parse_origin);
249249
if (!parsed_paragraph)
250250
{
251-
Checks::msg_exit_maybe_upgrade(
251+
Checks::msg_exit_with_message(
252252
VCPKG_LINE_INFO,
253253
msg::format(msgFailedToParseSerializedBinParagraph, msg::error_msg = parsed_paragraph.error())
254254
.append_raw('\n')
@@ -258,12 +258,12 @@ namespace vcpkg
258258
auto binary_paragraph = BinaryParagraph(sanity_parse_origin, std::move(*parsed_paragraph.get()));
259259
if (binary_paragraph != pgh)
260260
{
261-
Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO,
262-
msg::format(msgMismatchedBinParagraphs)
263-
.append(msgOriginalBinParagraphHeader)
264-
.append_raw(format_binary_paragraph(pgh))
265-
.append(msgSerializedBinParagraphHeader)
266-
.append_raw(format_binary_paragraph(binary_paragraph)));
261+
Checks::msg_exit_with_message(VCPKG_LINE_INFO,
262+
msg::format(msgMismatchedBinParagraphs)
263+
.append(msgOriginalBinParagraphHeader)
264+
.append_raw(format_binary_paragraph(pgh))
265+
.append(msgSerializedBinParagraphHeader)
266+
.append_raw(format_binary_paragraph(binary_paragraph)));
267267
}
268268
}
269269

src/vcpkg/commands.build.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ namespace vcpkg
435435
msg::println_error(msgInvalidArchitectureValue,
436436
msg::value = target_architecture,
437437
msg::expected = all_comma_separated_cpu_architectures());
438-
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO);
438+
Checks::exit_fail(VCPKG_LINE_INFO);
439439
}
440440

441441
auto target_arch = maybe_target_arch.value_or_exit(VCPKG_LINE_INFO);
@@ -464,7 +464,7 @@ namespace vcpkg
464464
msg::path = toolset.visual_studio_root_path,
465465
msg::list = toolset_list);
466466
msg::println(msgSeeURL, msg::url = docs::vcpkg_visual_studio_path_url);
467-
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO);
467+
Checks::exit_fail(VCPKG_LINE_INFO);
468468
}
469469
#endif
470470

@@ -1042,10 +1042,10 @@ namespace vcpkg
10421042
}
10431043
else
10441044
{
1045-
Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO,
1046-
msgUndeterminedToolChainForTriplet,
1047-
msg::triplet = triplet,
1048-
msg::system_name = cmake_system_name);
1045+
Checks::msg_exit_with_message(VCPKG_LINE_INFO,
1046+
msgUndeterminedToolChainForTriplet,
1047+
msg::triplet = triplet,
1048+
msg::system_name = cmake_system_name);
10491049
}
10501050
}
10511051

@@ -2144,7 +2144,7 @@ namespace vcpkg
21442144
return inner_create_buildinfo(filepath, std::move(*paragraph));
21452145
}
21462146

2147-
Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO, msgInvalidBuildInfo, msg::error_msg = maybe_paragraph.error());
2147+
Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgInvalidBuildInfo, msg::error_msg = maybe_paragraph.error());
21482148
}
21492149

21502150
static ExpectedL<bool> from_cmake_bool(StringView value, StringView name)

src/vcpkg/commands.edit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ namespace vcpkg
168168
if (!fs.is_directory(portpath))
169169
{
170170
msg::println_error(msgPortDoesNotExist, msg::package_name = port_name);
171-
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO);
171+
Checks::exit_fail(VCPKG_LINE_INFO);
172172
}
173173
}
174174

0 commit comments

Comments
 (0)