{"record":{"id":"9c5db5b599d1a6da","repo":"pulumi/pulumi","slug":"create-plugin-host-w-9c5db5","errorCode":null,"errorMessage":"create plugin host: %w","messagePattern":"create plugin host: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/operations/import.go","lineNumber":911,"sourceCode":"\n\t\t\tif from == \"terraform\" && importFilePath == \"\" && proj.Runtime.Name() == \"hcl\" {\n\t\t\t\treturn errors.New(\"`pulumi import --from terraform` will produce state that doesn't line up \" +\n\t\t\t\t\t\"with Pulumi's HCL runtime.\\nYou should run `pulumi import --from hcl` instead.\")\n\t\t\t}\n\n\t\t\tssml := cmdStack.NewStackSecretsManagerLoaderFromEnv()\n\n\t\t\tcwd, err := os.Getwd()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"get working directory: %w\", err)\n\t\t\t}\n\t\t\tsink := cmdutil.Diag()\n\t\t\treg := cmdCmd.NewDefaultRegistry(ctx, cmdBackend.DefaultLoginManager, ws, proj, sink, env.Global())\n\t\t\tpluginHost, err := pkghost.New(context.WithoutCancel(ctx), sink, sink, nil,\n\t\t\t\tpkgWorkspace.EnsureLanguageInstalled, schema.NewLoaderServerFromContext, convert.NewMapperServerFromContext,\n\t\t\t\tpackageworkspace.NewResolverServer(reg))\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"create plugin host: %w\", err)\n\t\t\t}\n\t\t\t// host is owned here, closed after the context\n\t\t\tdefer contract.IgnoreClose(pluginHost)\n\t\t\tpCtx, err := plugin.NewContext(ctx, sink, sink, pluginHost, nil, cwd, nil, true, nil)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"create plugin context: %w\", err)\n\t\t\t}\n\t\t\tdefer contract.IgnoreClose(pCtx)\n\n\t\t\tvar importFile importFile\n\t\t\tif importFilePath != \"\" {\n\t\t\t\tif len(args) != 0 || parentSpec != \"\" || providerSpec != \"\" || len(properties) != 0 {\n\t\t\t\t\tcontract.IgnoreError(cmd.Help())\n\t\t\t\t\treturn errors.New(\"an inline resource may not be specified in conjunction with an import file\")\n\t\t\t\t}\n\t\t\t\tif from != \"\" {\n\t\t\t\t\tcontract.IgnoreError(cmd.Help())\n\t\t\t\t\treturn errors.New(\"a converter may not be specified in conjunction with an import file\")","sourceCodeStart":893,"sourceCodeEnd":929,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/operations/import.go#L893-L929","documentation":"`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.","triggerScenarios":"`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.","commonSituations":"Corrupted plugin cache (`~/.pulumi/plugins`); incompatible or broken provider binaries; PATH/PULUMI_HOME misconfiguration; version mismatch between CLI and plugins after an upgrade.","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"],"exampleFix":"// before\n# corrupted plugin cache\npulumi import ...\n// after\npulumi plugin rm --all && pulumi import ...","handlingStrategy":"try-catch","validationCode":"// Verify plugin cache and CLI health before import\nexec.Command(\"pulumi\", \"plugin\", \"ls\").Run()\nexec.Command(\"pulumi\", \"about\").Run()","typeGuard":null,"tryCatchPattern":"// Go: catch host creation failure and retry after plugin cleanup\nerr := runImport()\nif err != nil && strings.Contains(err.Error(), \"create plugin host\") {\n    exec.Command(\"pulumi\", \"plugin\", \"rm\", \"--all\").Run()\n    err = runImport()\n}","preventionTips":["Keep the CLI and plugins at compatible versions","Clean the plugin cache after failed upgrades","Verify `pulumi about` works before scripted imports"],"tags":["plugins","plugin-host","cli"],"backgroundTag":"plugin-host-startup-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}