opentofu/opentofu · error

failed to create directory %s: %w

Error message

failed to create directory %s: %w

What it means

Error "failed to create directory %s: %w" thrown in opentofu/opentofu.

Source

Thrown at internal/getmodules/getter.go:185

	// that need before we introduce that complexity.
	//
	// NOTE WELL: [getter.Client.Get] modifies internal state inside each of the
	// getters passed in [getter.Client.Getters] before calling into them, so
	// it is _not_ safe to reuse the same getter instances across multiple
	// concurrent calls. If we want to make this work concurrently in future
	// then we'll need to instead instantiate the getters on demand for each
	// request.
	g.previousInstallsMu.Lock()
	defer g.previousInstallsMu.Unlock()
	if g.previousInstalls == nil {
		g.previousInstalls = make(map[string]string)
	}

	if prevDir, exists := g.previousInstalls[packageAddr]; exists {
		log.Printf("[TRACE] getmodules: copying previous install of %q from %s to %s", packageAddr, prevDir, instPath)
		err := os.Mkdir(instPath, os.ModePerm)
		if err != nil {
			return fmt.Errorf("failed to create directory %s: %w", instPath, err)
		}
		err = copy.CopyDir(instPath, prevDir)
		if err != nil {
			return fmt.Errorf("failed to copy from %s to %s: %w", prevDir, instPath, err)
		}
	} else {
		log.Printf("[TRACE] getmodules: fetching %q to %q", packageAddr, instPath)
		client := getter.Client{
			Src: packageAddr,
			Dst: instPath,
			Pwd: instPath,

			Mode: getter.ClientModeDir,

			Detectors:     goGetterNoDetectors, // our caller should've already done detection
			Decompressors: goGetterDecompressors,
			Getters:       g.getters,
			Ctx:           ctx,

View on GitHub (pinned to 3561785c48)

When it happens

Trigger: Thrown at internal/getmodules/getter.go:185 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of opentofu/opentofu@3561785c48 (2026-08-15). Data as JSON: /api/errors/c77e9e31837726a0. Report an issue: GitHub.