Skip to content

Commit

Permalink
Change the mismatched VCPKG_ROOT message to note which vcpkg.exe is e…
Browse files Browse the repository at this point in the history
…mitting the message for clarity. (#775)
  • Loading branch information
BillyONeal authored Oct 28, 2022
1 parent 78bc9ce commit 0614140
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines/end-to-end-tests-dir/vcpkg-root.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$CurrentTest = "VCPKG_ROOT"

$targetMessage = 'Ignoring VCPKG_ROOT environment variable'
$targetMessage = 'ignoring mismatched VCPKG_ROOT environment value'

$defaultOutput = Run-Vcpkg -TestArgs ($commonArgs + @('install', 'vcpkg-empty-port'))
Throw-IfFailed
Expand Down
9 changes: 5 additions & 4 deletions include/vcpkg/base/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -1263,10 +1263,11 @@ namespace vcpkg
DECLARE_MESSAGE(HelpVersionStringScheme, (), "", "An exact, incomparable version (Vista)");
DECLARE_MESSAGE(
IgnoringVcpkgRootEnvironment,
(msg::path, msg::actual),
"{actual} is the path we actually used",
"Ignoring VCPKG_ROOT environment variable; use --vcpkg-root \"{path}\" to use the environment value or unset "
"the VCPKG_ROOT environment variable to suppress this message. Using detected vcpkg root: \"{actual}\".");
(msg::path, msg::actual, msg::value),
"{actual} is the path we actually used, {value} is the path to vcpkg's binary",
"The vcpkg {value} is using detected vcpkg root {actual} and ignoring mismatched VCPKG_ROOT environment "
"value {path}. To suppress this message, unset the environment variable or use the --vcpkg-root command line "
"switch.");
DECLARE_MESSAGE(IllegalFeatures, (), "", "List of features is not allowed in this context");
DECLARE_MESSAGE(IllegalPlatformSpec, (), "", "Platform qualifier is not allowed in this context");
DECLARE_MESSAGE(ImproperShaLength,
Expand Down
2 changes: 1 addition & 1 deletion locales/messages.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
"HelpVersionSemverScheme": "A Semantic Version 2.0 (2.1.0-rc2)",
"HelpVersionStringScheme": "An exact, incomparable version (Vista)",
"HelpVersioning": "Versioning allows you to deterministically control the precise revisions of dependencies used by your project from within your manifest file.",
"IgnoringVcpkgRootEnvironment": "Ignoring VCPKG_ROOT environment variable; use --vcpkg-root \"{path}\" to use the environment value or unset the VCPKG_ROOT environment variable to suppress this message. Using detected vcpkg root: \"{actual}\".",
"IgnoringVcpkgRootEnvironment": "The vcpkg {value} is using detected vcpkg root {actual} and ignoring mismatched VCPKG_ROOT environment value {path}. To suppress this message, unset the environment variable or use the --vcpkg-root command line switch.",
"IllegalFeatures": "List of features is not allowed in this context",
"IllegalPlatformSpec": "Platform qualifier is not allowed in this context",
"ImproperShaLength": "SHA512's must be 128 hex characters: {value}",
Expand Down
4 changes: 2 additions & 2 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,8 @@
"HelpVersionSemverScheme": "A Semantic Version 2.0 (2.1.0-rc2)",
"HelpVersionStringScheme": "An exact, incomparable version (Vista)",
"HelpVersioning": "Versioning allows you to deterministically control the precise revisions of dependencies used by your project from within your manifest file.",
"IgnoringVcpkgRootEnvironment": "Ignoring VCPKG_ROOT environment variable; use --vcpkg-root \"{path}\" to use the environment value or unset the VCPKG_ROOT environment variable to suppress this message. Using detected vcpkg root: \"{actual}\".",
"_IgnoringVcpkgRootEnvironment.comment": "{actual} is the path we actually used An example of {path} is /foo/bar.",
"IgnoringVcpkgRootEnvironment": "The vcpkg {value} is using detected vcpkg root {actual} and ignoring mismatched VCPKG_ROOT environment value {path}. To suppress this message, unset the environment variable or use the --vcpkg-root command line switch.",
"_IgnoringVcpkgRootEnvironment.comment": "{actual} is the path we actually used, {value} is the path to vcpkg's binary An example of {path} is /foo/bar.",
"IllegalFeatures": "List of features is not allowed in this context",
"IllegalPlatformSpec": "Platform qualifier is not allowed in this context",
"ImproperShaLength": "SHA512's must be 128 hex characters: {value}",
Expand Down
12 changes: 6 additions & 6 deletions src/vcpkg/vcpkgpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,13 +585,11 @@ namespace vcpkg
}
else
{
const auto canonical_current_exe = fs.almost_canonical(get_exe_path_of_current_process(), VCPKG_LINE_INFO);
ret = fs.find_file_recursively_up(original_cwd, ".vcpkg-root", VCPKG_LINE_INFO);
if (ret.empty())
{
ret =
fs.find_file_recursively_up(fs.almost_canonical(get_exe_path_of_current_process(), VCPKG_LINE_INFO),
".vcpkg-root",
VCPKG_LINE_INFO);
ret = fs.find_file_recursively_up(canonical_current_exe, ".vcpkg-root", VCPKG_LINE_INFO);
}

if (auto vcpkg_root_dir_env = args.vcpkg_root_dir_env.get())
Expand All @@ -603,8 +601,10 @@ namespace vcpkg
}
else if (ret != canonical_root_dir_env)
{
msg::println_warning(
msgIgnoringVcpkgRootEnvironment, msg::path = *vcpkg_root_dir_env, msg::actual = ret);
msg::println_warning(msgIgnoringVcpkgRootEnvironment,
msg::path = *vcpkg_root_dir_env,
msg::actual = ret,
msg::value = canonical_current_exe);
}
}
}
Expand Down

0 comments on commit 0614140

Please sign in to comment.