Skip to content

Corrupted PowerShellProperties.json prevents powershell from starting #2342

Closed

Description

@vors

Steps to reproduce

Corruption of this file can happen for natural reasons (i.e. file was not flushed, but process died).
You can corrupt it artificially.

I.e.

'' > src\powershell-win-core\bin\Debug\netcoreapp1.0\win10-x64\PowerShellProperties.json
src\powershell-win-core\bin\Debug\netcoreapp1.0\win10-x64\powershell.exe

Expected behavior

PowerShell should be able to run

Actual behavior

C:\Users\sevoroby>F:\dev\PowerShell/src/powershell-win-core\bin\Debug\netcoreapp1.0\win10-x64\powershell.exe
PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

The shell cannot be started. A failure occurred during initialization:
Error reading JToken from JsonReader. Path '', line 0, position 0.

C:\Users\sevoroby>

PowerShell cannot run.
Removing the file fixes the problem.

I propose to handle this error gracefully: if file is corrupted, we should re-create it, like it was not present at all.

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
CLRVersion
GitCommitId                    v6.0.0-alpha.10
PSRemotingProtocolVersion      2.3
PSEdition                      Core
SerializationVersion           1.1.0.1
BuildVersion                   3.0.0.0
WSManStackVersion              3.0
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}

Activity

  1. added
    Area-SideBySiderelated to ability to run PS7 side-by-side with WinPS or different versions of PS7
    on Sep 22, 2016
  2. vors commented on Sep 22, 2016

    @vors
    CollaboratorAuthor
  3. mirichmo commented on Sep 22, 2016

    @mirichmo
    Member

    This request is similar to #1614 (add Schema validation to the JSON file), but addresses a different aspect of file validation

  4. added
    Issue-BugIssue has been identified as a bug in the product
    Issue-Enhancementthe issue is more of a feature request than a bug
    and removed
    Issue-Enhancementthe issue is more of a feature request than a bug
    Issue-BugIssue has been identified as a bug in the product
    on Sep 27, 2016
  5. mirichmo commented on Sep 27, 2016

    @mirichmo
    Member

    The simplest repro is to empty the config file:

    Set-Content <path to config file> -Value "{}"

    and then restart PowerShell. Give it invalid contents to trigger the scenario specified here.

  6. added
    Issue-BugIssue has been identified as a bug in the product
    and removed
    Issue-Enhancementthe issue is more of a feature request than a bug
    on Sep 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area-SideBySiderelated to ability to run PS7 side-by-side with WinPS or different versions of PS7Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions