{"record":{"id":"5635ceae09ffb734","repo":"pulumi/pulumi","slug":"create-plugin-context-w-5635ce","errorCode":null,"errorMessage":"create plugin context: %w","messagePattern":"create plugin context: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/operations/import.go","lineNumber":917,"sourceCode":"\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\")\n\t\t\t\t}\n\t\t\t\tf, err := readImportFile(importFilePath)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not read import file: %w\", err)\n\t\t\t\t}\n\t\t\t\timportFile = f","sourceCodeStart":899,"sourceCodeEnd":935,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/operations/import.go#L899-L935","documentation":"The `pulumi import` command creates a plugin context (host + gRPC plumbing) before reading resources. `plugin.NewContext` failing is wrapped with \"create plugin context: %w\". This is an internal setup failure that prevents any import work from starting.","triggerScenarios":"Running `pulumi import` when plugin.NewContext(ctx, sink, sink, pluginHost, nil, cwd, nil, true, nil) fails — typically because the current working directory is invalid (deleted cwd), or plugin host startup/connection failed.","commonSituations":"Running the CLI from a deleted directory; corrupted PULUMI_HOME plugin cache; environment or Go plugin loading issues on the machine.","solutions":["Re-run the command from an existing directory (cd to your project root).","Check PULUMI_HOME/plugin cache permissions and disk space.","Update the pulumi CLI and retry; include the wrapped inner error in a bug report if it persists."],"exampleFix":"// before: run in a shell whose cwd was deleted\npulumi import ...\n// after\ncd /path/to/project && pulumi import ...","handlingStrategy":"retry","validationCode":"// ensure cwd exists before invoking the CLI\nif [ ! -d \"$PWD\" ]; then echo \"cwd missing\"; fi; pulumi about","typeGuard":null,"tryCatchPattern":"try {\n  execSync('pulumi import ...', { cwd: projectRoot })\n} catch (e) {\n  if (/create plugin context/.test(e.message)) retry from a valid cwd or report bug with wrapped cause\n}","preventionTips":["Always run pulumi from an existing project directory","Keep the plugin cache ($PULUMI_HOME/plugins) writable and on disk with free space","Keep the CLI up to date"],"tags":["cli","plugin-host","pulumi-import"],"backgroundTag":"plugin-context-setup-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}