pulumi/pulumi · error
create plugin host: %w
Error message
create plugin host: %w
What it means
`pulumi import` starts a plugin host via `pkghost.New` (wired with language install, schema loader, conversion mapper, and package resolver servers). If host construction fails — bad workspace/project state, missing plugin infrastructure, or internal RPC server startup errors — the error is wrapped as 'create plugin host' and the import aborts before touching state.
Source
Thrown at pkg/cmd/pulumi/operations/import.go:911
if from == "terraform" && importFilePath == "" && proj.Runtime.Name() == "hcl" {
return errors.New("`pulumi import --from terraform` will produce state that doesn't line up " +
"with Pulumi's HCL runtime.\nYou should run `pulumi import --from hcl` instead.")
}
ssml := cmdStack.NewStackSecretsManagerLoaderFromEnv()
cwd, err := os.Getwd()
if err != nil {
return fmt.Errorf("get working directory: %w", err)
}
sink := cmdutil.Diag()
reg := cmdCmd.NewDefaultRegistry(ctx, cmdBackend.DefaultLoginManager, ws, proj, sink, env.Global())
pluginHost, err := pkghost.New(context.WithoutCancel(ctx), sink, sink, nil,
pkgWorkspace.EnsureLanguageInstalled, schema.NewLoaderServerFromContext, convert.NewMapperServerFromContext,
packageworkspace.NewResolverServer(reg))
if err != nil {
return fmt.Errorf("create plugin host: %w", err)
}
// host is owned here, closed after the context
defer contract.IgnoreClose(pluginHost)
pCtx, err := plugin.NewContext(ctx, sink, sink, pluginHost, nil, cwd, nil, true, nil)
if err != nil {
return fmt.Errorf("create plugin context: %w", err)
}
defer contract.IgnoreClose(pCtx)
var importFile importFile
if importFilePath != "" {
if len(args) != 0 || parentSpec != "" || providerSpec != "" || len(properties) != 0 {
contract.IgnoreError(cmd.Help())
return errors.New("an inline resource may not be specified in conjunction with an import file")
}
if from != "" {
contract.IgnoreError(cmd.Help())
return errors.New("a converter may not be specified in conjunction with an import file")View on GitHub (pinned to 793f7b2e16)
Solutions
- Read the wrapped inner error for the root cause and fix that first
- Clear/reinstall plugins: `pulumi plugin rm --all` then re-run so plugins are fetched fresh
- Ensure `PULUMI_HOME`/PATH point to a valid install; retry after upgrading the CLI
Example fix
// before # corrupted plugin cache pulumi import ... // after pulumi plugin rm --all && pulumi import ...
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify plugin cache and CLI health before import
exec.Command("pulumi", "plugin", "ls").Run()
exec.Command("pulumi", "about").Run() Try / catch
// Go: catch host creation failure and retry after plugin cleanup
err := runImport()
if err != nil && strings.Contains(err.Error(), "create plugin host") {
exec.Command("pulumi", "plugin", "rm", "--all").Run()
err = runImport()
} Prevention
- Keep the CLI and plugins at compatible versions
- Clean the plugin cache after failed upgrades
- Verify `pulumi about` works before scripted imports
When it happens
Trigger: `pulumi import` invocation where `pkghost.New` returns an error: e.g. failure launching the host, resolver/registry misconfiguration, or failures initializing gRPC servers for schema loading or conversion.
Common situations: Corrupted plugin cache (`~/.pulumi/plugins`); incompatible or broken provider binaries; PATH/PULUMI_HOME misconfiguration; version mismatch between CLI and plugins after an upgrade.
Related errors
- building plugin host: %w
- installing `packages` from PulumiPlugin.yaml: %w
- load language plugin %s: %w
- create plugin context: %w
- get mapping: %w
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/9c5db5b599d1a6da.
Report an issue: GitHub.