From 1fb9cb43ba737b8a67e7ffb12892f8ba4e60772e Mon Sep 17 00:00:00 2001 From: Christian Mesh Date: Thu, 2 Apr 2026 07:36:10 -0400 Subject: [PATCH] Add warning when provider symlinks fail (#3974) Signed-off-by: Christian Mesh Co-authored-by: Martin Atkins --- internal/getproviders/package_location_local_dir.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/getproviders/package_location_local_dir.go b/internal/getproviders/package_location_local_dir.go index b3f7ccc4ea..f9c1f86a40 100644 --- a/internal/getproviders/package_location_local_dir.go +++ b/internal/getproviders/package_location_local_dir.go @@ -8,8 +8,10 @@ package getproviders import ( "context" "fmt" + "log" "os" "path/filepath" + "runtime" "github.com/opentofu/opentofu/internal/copy" ) @@ -129,6 +131,12 @@ func (p PackageLocalDir) InstallProviderPackage(_ context.Context, meta PackageM // If we get down here then symlinking failed and we need a deep copy // instead. To make a copy, we first need to create the target directory, // which would otherwise be a symlink. + warning := fmt.Sprintf("[WARN] Failed to create provider symlink: %s. Falling back to copying the package.", err) + if runtime.GOOS == "windows" { + warning += " Refer to https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/security-policy-settings/create-symbolic-links for limitations of symlink support on Windows." + } + log.Print(warning) + //nolint:mnd // magic number predates us using this linter err = os.Mkdir(absNew, 0755) if err != nil && os.IsExist(err) {