{"record":{"id":"9932ba6f80bfb459","repo":"PowerShell/PowerShell","slug":"the-shell-cannot-be-started-a-failure-occurred-du","errorCode":null,"errorMessage":"The shell cannot be started. A failure occurred during initialization:","messagePattern":"The shell cannot be started\\. A failure occurred during initialization:","errorType":"exception","errorClass":"ConsoleHostStartupException","httpStatus":null,"severity":"critical","filePath":"src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs","lineNumber":1722,"sourceCode":"            Dbg.Assert(_runspaceRef == null, \"_runspaceRef field should be null\");\n            Dbg.Assert(DefaultInitialSessionState != null, \"DefaultInitialSessionState should not be null\");\n            s_runspaceInitTracer.WriteLine(\"Calling RunspaceFactory.CreateRunspace\");\n\n            // Use session configuration file if provided.\n            bool customConfigurationProvided = false;\n            if (!string.IsNullOrEmpty(args.ConfigurationFilePath))\n            {\n                try\n                {\n                    // Replace DefaultInitialSessionState with the initial state configuration defined by the file.\n                    DefaultInitialSessionState = InitialSessionState.CreateFromSessionConfigurationFile(\n                        path: args.ConfigurationFilePath,\n                        roleVerifier: null,\n                        validateFile: true);\n                }\n                catch (Exception ex)\n                {\n                    throw new ConsoleHostStartupException(ConsoleHostStrings.ShellCannotBeStarted, ex);\n                }\n\n                customConfigurationProvided = true;\n            }\n\n            try\n            {\n                Runspace consoleRunspace = null;\n                bool psReadlineFailed = false;\n\n                // Load PSReadline by default unless there is no use:\n                //    - we're running a command/file and just exiting\n                //    - stdin is redirected by a parent process\n                //    - we're not interactive\n                //    - we're explicitly reading from stdin (the '-' argument)\n                // It's also important to have a scenario where PSReadline is not loaded so it can be updated, e.g.\n                //    powershell -command \"Update-Module PSReadline\"\n                // This should work just fine as long as no other instances of PowerShell are running.","sourceCodeStart":1704,"sourceCodeEnd":1740,"githubUrl":"https://github.com/PowerShell/PowerShell/blob/3ff3c711bf54a18f8440f3c5190c3ac91cdc5852/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs#L1704-L1740","documentation":"During startup, ConsoleHost loads the session configuration from the -ConfigurationFile path via InitialSessionState.CreateFromSessionConfigurationFile (with validateFile:true). Any exception thrown by that load is wrapped in ConsoleHostStartupException 'ShellCannotBeStarted', so the message alone is generic — the real cause is in the InnerException.","triggerScenarios":"Passing -ConfigurationFile pointing at a .pssc file that is missing, unreadable, malformed, fails schema/signature validation, or is rejected by the role verifier.","commonSituations":"Typo in the config path; corrupt or hand-edited .pssc; file written by an incompatible PowerShell version; permission denied reading the file; signing/validation failure on a locked-down system.","solutions":["Inspect InnerException of the thrown ConsoleHostStartupException to get the precise cause (file not found, schema error, etc.).","Validate the .pssc path exists and is readable before launch.","Re-generate or re-sign the .pssc with a current PowerShell; run Test-PSSessionConfigurationFile on it.","Fix file permissions so the host account can read the config."],"exampleFix":"// diagnose\ntry { /* start host with -ConfigurationFile */ }\ncatch (ConsoleHostStartupException ex) { Log(ex.InnerException); } // real reason\n// then repair the .pssc or correct the path","handlingStrategy":"validation","validationCode":"if (!File.Exists(args.ConfigurationFilePath)) throw new FileNotFoundException(args.ConfigurationFilePath);\n// optionally pre-validate the .pssc schema/signature before launch","typeGuard":"// not applicable","tryCatchPattern":"try { /* start with -ConfigurationFile */ }\ncatch (ConsoleHostStartupException ex)\n{ var cause = ex.InnerException ?? ex; /* inspect cause, fix file */ }","preventionTips":["Run Test-PSSessionConfigurationFile on the .pssc before launch.","Keep .pssc files version-aligned with the PowerShell build.","Verify read permissions for the host account."],"tags":["console-host","startup","configuration","session-config","pssc"],"backgroundTag":null,"analyzedSha":"3ff3c711bf54a18f8440f3c5190c3ac91cdc5852","analyzedAt":"2026-08-13T10:39:10.759Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}