pulumi/pulumi · error

can not read '%s': %w

Error message

can not read '%s': %w

What it means

LoadProject in sdk/go/common/workspace/loaders.go returns this error when marshallerForPath fails — i.e. the file's extension does not map to a supported marshaller (YAML/JSON). Despite the 'can not read' wording, it is raised before the file is actually read; the wrapped error explains why no marshaller could be chosen. Note the confusing similarity with the later 'could not read' message, which covers actual file I/O.

Source

Thrown at sdk/go/common/workspace/loaders.go:97

					modifiedConfig[namespacedKey] = value
				}
			}

			projectStack["config"] = modifiedConfig
			return projectStack
		}
	}

	return projectStack
}

// LoadProject reads a project definition from a file.
func LoadProject(path string) (*Project, error) {
	contract.Requiref(path != "", "path", "must not be empty")

	marshaller, err := marshallerForPath(path)
	if err != nil {
		return nil, fmt.Errorf("can not read '%s': %w", path, err)
	}

	b, err := readFileStripUTF8BOM(path)
	if err != nil {
		return nil, fmt.Errorf("could not read '%s': %w", path, err)
	}

	return LoadProjectBytes(b, path, marshaller)
}

// LoadProjectBytes reads a project definition from a byte slice.
func LoadProjectBytes(b []byte, path string, marshaller encoding.Marshaler) (*Project, error) {
	var raw any
	err := marshaller.Unmarshal(b, &raw)
	if err != nil {
		return nil, fmt.Errorf("could not unmarshal '%s': %w", path, err)
	}

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Rename the project file to a supported name: Pulumi.yaml, Pulumi.yml, or Pulumi.json.
  2. Check the wrapped error to confirm it is an unsupported-format issue rather than permissions.
  3. Pass a path with a recognized extension if calling LoadProgram-like helpers programmatically.
  4. Inspect the directory listing: the file may be misspelled (e.g. Pulimai.yaml).

Example fix

// before
proj, err := workspace.LoadProject("Pulumi.PUL.yml.orig")
// after
proj, err := workspace.LoadProject("Pulumi.yaml")
Defensive patterns

Strategy: validation

Validate before calling

ext := strings.ToLower(filepath.Ext(path))
switch ext {
case ".yaml", ".yml", ".json":
    // ok
default:
    return fmt.Errorf("%s has unsupported extension %q; use .yaml/.yml/.json", path, ext)
}

Try / catch

proj, err := workspace.LoadProject(path)
if err != nil {
    if strings.HasPrefix(err.Error(), "can not read '") {
        return fmt.Errorf("unsupported project format for %s: %w", path, err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling workspace.LoadProject(path) with a file whose extension is not .yaml/.yml/.json (e.g. Pulumipack or a .txt project file), or marshallerForPath returning an unsupported-format error.

Common situations: Renaming Pulumi.yaml to Pulumi.yml2 or an unusual extension; pointing LoadProject at a directory or config file with no recognized extension; tooling generating project files with the wrong suffix.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/318e37a8be9dd7c8. Report an issue: GitHub.