Add warning when provider symlinks fail (#3974)

Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
Christian Mesh
2026-04-02 07:36:10 -04:00
committed by GitHub
parent c874a1c8fd
commit 1fb9cb43ba

View File

@@ -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) {