[vcpkg] Add x-ignore-lock-failures
* [vcpkg] Add disable-lock options
This should fix at least as a stopgap.
Additionally, adds better errors.
* billy CRs
* change from "disable-lock" to "allow-spurious-lock-failures"
* billy cr
MODIFY
include/vcpkg/vcpkgcmdarguments.h
include/vcpkg/vcpkgcmdarguments.h
@@ -163,6 +163,10 @@ namespace vcpkg
constexpr static StringLiteral WAIT_FOR_LOCK_SWITCH = "x-wait-for-lock";
Optional<bool> wait_for_lock = nullopt;
+ constexpr static StringLiteral IGNORE_LOCK_FAILURES_SWITCH = "x-ignore-lock-failures";
+ constexpr static StringLiteral IGNORE_LOCK_FAILURES_ENV = "X_VCPKG_IGNORE_LOCK_FAILURES";
+ Optional<bool> ignore_lock_failures = nullopt;
+
constexpr static StringLiteral JSON_SWITCH = "x-json";
Optional<bool> json = nullopt;

MODIFY
src/vcpkg/vcpkgcmdarguments.cpp
src/vcpkg/vcpkgcmdarguments.cpp
@@ -293,6 +293,7 @@ namespace vcpkg
{FEATURE_PACKAGES_SWITCH, &VcpkgCmdArguments::feature_packages},
{BINARY_CACHING_SWITCH, &VcpkgCmdArguments::binary_caching},
{WAIT_FOR_LOCK_SWITCH, &VcpkgCmdArguments::wait_for_lock},
+ {IGNORE_LOCK_FAILURES_SWITCH, &VcpkgCmdArguments::ignore_lock_failures},
{JSON_SWITCH, &VcpkgCmdArguments::json},
};
@@ -662,6 +663,14 @@ namespace vcpkg
from_env(DOWNLOADS_ROOT_DIR_ENV, downloads_root_dir);
from_env(DEFAULT_VISUAL_STUDIO_PATH_ENV, default_visual_studio_path);
+ {
+ const auto vcpkg_disable_lock = System::get_environment_variable(IGNORE_LOCK_FAILURES_ENV);
+ if (vcpkg_disable_lock.has_value() && !ignore_lock_failures.has_value())
+ {
+ ignore_lock_failures = true;
+ }
+ }
+
{
const auto vcpkg_overlay_ports_env = System::get_environment_variable(OVERLAY_PORTS_ENV);
if (const auto unpacked = vcpkg_overlay_ports_env.get())
@@ -923,6 +932,8 @@ namespace vcpkg
constexpr StringLiteral VcpkgCmdArguments::PRINT_METRICS_SWITCH;
constexpr StringLiteral VcpkgCmdArguments::WAIT_FOR_LOCK_SWITCH;
+ constexpr StringLiteral VcpkgCmdArguments::IGNORE_LOCK_FAILURES_SWITCH;
+ constexpr StringLiteral VcpkgCmdArguments::IGNORE_LOCK_FAILURES_ENV;
constexpr StringLiteral VcpkgCmdArguments::JSON_SWITCH;

MODIFY
src/vcpkg/vcpkgpaths.cpp
src/vcpkg/vcpkgpaths.cpp
@@ -259,6 +259,7 @@ namespace vcpkg
installed = process_output_directory(
filesystem, manifest_root_dir, args.install_root_dir.get(), "vcpkg_installed", VCPKG_LINE_INFO);
+
const auto vcpkg_lock = root / ".vcpkg-root";
if (args.wait_for_lock.value_or(false))
{
@@ -268,13 +269,17 @@ namespace vcpkg
{
m_pimpl->file_lock_handle = filesystem.try_take_exclusive_file_lock(vcpkg_lock, ec);
}
+
if (ec)
+ {
+ if (ec == std::errc::device_or_resource_busy || args.ignore_lock_failures.value_or(false))
{
System::printf(
System::Color::error, "Failed to take the filesystem lock on %s:\n", fs::u8string(vcpkg_lock));
System::printf(System::Color::error, " %s\n", ec.message());
Checks::exit_fail(VCPKG_LINE_INFO);
}
+ }
m_pimpl->m_manifest_doc = load_manifest(filesystem, manifest_root_dir);
m_pimpl->m_manifest_path = manifest_root_dir / fs::u8path("vcpkg.json");

[vcpkg] Add x-ignore-lock-failures (#14397)

* [vcpkg] Add disable-lock options

This should fix #14281 at least as a stopgap.

Additionally, adds better errors.

* billy CRs

* change from "disable-lock" to "allow-spurious-lock-failures"

* billy cr