microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.39k stars 28.62k forks source link

Unterminated string in JSON at position 4096 #225942

Closed loserlulin9 closed 1 week ago

loserlulin9 commented 3 weeks ago

Does this issue occur when all extensions are disabled?: Unknown

Sorry and thanks. I have suffered a bug about the Python plugin and I don't know how to reproduce it.

My python series plugin (include Python, Pylance, Python Debugger...) can't work in my remote server (see the picture-1 below). When I want to click the button "Install in SSH:...", I suffer the warning in the left lower part that "Unterminated string in JSON at position 4096". This means that I can't use the python plugin function, but I can still run "python main.py" in my terminal. So it's not too bad.

I can use python plugin normally for local use. And my teammates can also use the remote server normally. So I suspect that it is a bug about my VSCode.

I also found that I can't even open the "File -> Preferences -> Settings" (see the picture-2&3 below) for the same reason "Unterminated string in JSON at position 4096".

Could you help me? MANY THANKS!!!

image

image

image

gjsjohnmurray commented 3 weeks ago

Please use the Command Palette option to open your user settings JSON file. Then you should be able to correct it's syntax.

loserlulin9 commented 3 weeks ago

Thanks, I can open the user setting JSON and be able to change some basic settings like theme, font, ... But I can't not still use the Python-series extensions.

image

gjsjohnmurray commented 3 weeks ago

If you use the command to open the remote settings JSON does the Problems tab show any entries for that file?

If not, what about the workspace settings JSON?

loserlulin9 commented 3 weeks ago

I use "Ctrl + Shift + P" to open the user setting json and workspace setting json of my remote server. It seems that no problems in these two json files.

image

image

gjsjohnmurray commented 3 weeks ago

Maybe https://github.com/microsoft/vscode/issues/206678#issuecomment-1976459291 is relevant. Perhaps the unterminated string is in that file.

Pinging @sandy081

loserlulin9 commented 3 weeks ago

Here is my extensions.json following the https://github.com/microsoft/vscode/issues/206678#issuecomment-1976459291 . I don't find any problems here :(

[
    {
        "identifier": {
            "id": "ms-vscode-remote.remote-wsl",
            "uuid": "f0c5397b-d357-4197-99f0-cb4202f22818"
        },
        "version": "0.88.2",
        "location": {
            "$mid": 1,
            "path": "/c:/Users/loserlulin/.vscode/extensions/ms-vscode-remote.remote-wsl-0.88.2",
            "scheme": "file"
        },
        "relativeLocation": "ms-vscode-remote.remote-wsl-0.88.2",
        "metadata": {
            "installedTimestamp": 1724036349237,
            "source": "gallery",
            "id": "f0c5397b-d357-4197-99f0-cb4202f22818",
            "publisherId": "ac9410a2-0d75-40ec-90de-b59bb705801d",
            "publisherDisplayName": "Microsoft",
            "targetPlatform": "undefined",
            "updated": false,
            "isPreReleaseVersion": false,
            "hasPreReleaseVersion": false
        }
    },
    {
        "identifier": {
            "id": "ms-vscode-remote.remote-ssh-edit",
            "uuid": "bfeaf631-bcff-4908-93ed-fda4ef9a0c5c"
        },
        "version": "0.86.0",
        "location": {
            "$mid": 1,
            "path": "/c:/Users/loserlulin/.vscode/extensions/ms-vscode-remote.remote-ssh-edit-0.86.0",
            "scheme": "file"
        },
        "relativeLocation": "ms-vscode-remote.remote-ssh-edit-0.86.0",
        "metadata": {
            "installedTimestamp": 1724036363212,
            "pinned": false,
            "source": "gallery",
            "id": "bfeaf631-bcff-4908-93ed-fda4ef9a0c5c",
            "publisherId": "ac9410a2-0d75-40ec-90de-b59bb705801d",
            "publisherDisplayName": "Microsoft",
            "targetPlatform": "undefined",
            "updated": false,
            "isPreReleaseVersion": false,
            "hasPreReleaseVersion": false
        }
    },
    {
        "identifier": {
            "id": "ms-vscode-remote.remote-ssh",
            "uuid": "607fd052-be03-4363-b657-2bd62b83d28a"
        },
        "version": "0.113.1",
        "location": {
            "$mid": 1,
            "path": "/c:/Users/loserlulin/.vscode/extensions/ms-vscode-remote.remote-ssh-0.113.1",
            "scheme": "file"
        },
        "relativeLocation": "ms-vscode-remote.remote-ssh-0.113.1",
        "metadata": {
            "installedTimestamp": 1724036363211,
            "pinned": false,
            "source": "gallery",
            "id": "607fd052-be03-4363-b657-2bd62b83d28a",
            "publisherId": "ac9410a2-0d75-40ec-90de-b59bb705801d",
            "publisherDisplayName": "Microsoft",
            "targetPlatform": "undefined",
            "updated": false,
            "isPreReleaseVersion": false,
            "hasPreReleaseVersion": false
        }
    },
    {
        "identifier": {
            "id": "ms-vscode.remote-explorer",
            "uuid": "11858313-52cc-4e57-b3e4-d7b65281e34b"
        },
        "version": "0.4.3",
        "location": {
            "$mid": 1,
            "path": "/c:/Users/loserlulin/.vscode/extensions/ms-vscode.remote-explorer-0.4.3",
            "scheme": "file"
        },
        "relativeLocation": "ms-vscode.remote-explorer-0.4.3",
        "metadata": {
            "installedTimestamp": 1724036363212,
            "pinned": false,
            "source": "gallery",
            "id": "11858313-52cc-4e57-b3e4-d7b65281e34b",
            "publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",
            "publisherDisplayName": "Microsoft",
            "targetPlatform": "undefined",
            "updated": false,
            "isPreReleaseVersion": false,
            "hasPreReleaseVersion": false
        }
    },
    {
        "identifier": {
            "id": "ms-python.debugpy",
            "uuid": "4bd5d2c9-9d65-401a-b0b2-7498d9f17615"
        },
        "version": "2024.10.0",
        "location": {
            "$mid": 1,
            "path": "/c:/Users/loserlulin/.vscode/extensions/ms-python.debugpy-2024.10.0-win32-x64",
            "scheme": "file"
        },
        "relativeLocation": "ms-python.debugpy-2024.10.0-win32-x64",
        "metadata": {
            "installedTimestamp": 1724036672255,
            "pinned": false,
            "source": "gallery",
            "id": "4bd5d2c9-9d65-401a-b0b2-7498d9f17615",
            "publisherId": "998b010b-e2af-44a5-a6cd-0b5fd3b9b6f8",
            "publisherDisplayName": "Microsoft",
            "targetPlatform": "win32-x64",
            "updated": false,
            "isPreReleaseVersion": false,
            "hasPreReleaseVersion": false
        }
    },
    {
        "identifier": {
            "id": "ms-python.vscode-pylance",
            "uuid": "364d2426-116a-433a-a5d8-a5098dc3afbd"
        },
        "version": "2024.8.1",
        "location": {
            "$mid": 1,
            "path": "/c:/Users/loserlulin/.vscode/extensions/ms-python.vscode-pylance-2024.8.1",
            "scheme": "file"
        },
        "relativeLocation": "ms-python.vscode-pylance-2024.8.1",
        "metadata": {
            "installedTimestamp": 1724036672255,
            "pinned": false,
            "source": "gallery",
            "id": "364d2426-116a-433a-a5d8-a5098dc3afbd",
            "publisherId": "998b010b-e2af-44a5-a6cd-0b5fd3b9b6f8",
            "publisherDisplayName": "Microsoft",
            "targetPlatform": "undefined",
            "updated": false,
            "isPreReleaseVersion": false,
            "hasPreReleaseVersion": false
        }
    },
    {
        "identifier": {
            "id": "ms-python.python",
            "uuid": "f1f59ae4-9318-4f3c-a9b5-81b2eaa5f8a5"
        },
        "version": "2024.13.2024081501",
        "location": {
            "$mid": 1,
            "path": "/c:/Users/loserlulin/.vscode/extensions/ms-python.python-2024.13.2024081501-win32-x64",
            "scheme": "file"
        },
        "relativeLocation": "ms-python.python-2024.13.2024081501-win32-x64",
        "metadata": {
            "isApplicationScoped": false,
            "isMachineScoped": false,
            "isBuiltin": false,
            "installedTimestamp": 1724037015797,
            "pinned": false,
            "source": "gallery",
            "id": "f1f59ae4-9318-4f3c-a9b5-81b2eaa5f8a5",
            "publisherId": "998b010b-e2af-44a5-a6cd-0b5fd3b9b6f8",
            "publisherDisplayName": "Microsoft",
            "targetPlatform": "win32-x64",
            "updated": true,
            "isPreReleaseVersion": true,
            "hasPreReleaseVersion": true,
            "preRelease": true
        }
    }
]
roblourens commented 3 weeks ago

Can you check for errors in the Output pane? Check the Window and Remote Extension Host logs. Or check in devtools (Help > Toggle Developer Tools). I'm not sure which other file it would be, if not one of these.

loserlulin9 commented 3 weeks ago

When I click the button "Install in SSH: ...", this is what the OUTPUT prints.

2024-08-20 09:12:33.111 [debug] Remote Install Error Name Scanning
2024-08-20 09:12:33.113 [trace] pickRunningLocation for ms-python.python, extension kinds: [workspace], isInstalledLocally: true, isInstalledRemotely: false, preference: None => None
2024-08-20 09:12:33.116 [trace] pickRunningLocation for ms-python.python, extension kinds: [workspace], isInstalledLocally: true, isInstalledRemotely: false, preference: None => None
2024-08-20 09:12:33.118 [error] Unterminated string in JSON at position 4096: SyntaxError: Unterminated string in JSON at position 4096
    at JSON.parse (<anonymous>)
    at Object.factory (/home/luling/.vscode-server/cli/servers/Stable-fee1edb8d6d72a0ddff41e5f71a671c23ed924b9/server/out/vs/server/node/server.main.js:172:45171)

image

roblourens commented 3 weeks ago

Related to your profile somehow, are you using a profile?

cc @sandy081 I think this is the location with the error: https://github.com/microsoft/vscode/blob/9550d27676254ee870e7b6bae419e184b2f55ab4/src/vs/platform/extensionManagement/common/extensionsProfileScannerService.ts#L232

loserlulin9 commented 3 weeks ago

I just use the default profile.

roblourens commented 3 weeks ago

It looks like you shared the local extensions.json, but there is also one on your remote and I think this would be complaining about that, if you can find it.

loserlulin9 commented 3 weeks ago

This is what the "F1 -> Open Remote User Settings (JSON)" shows. Is it right?

{
    "python.languageServer": "Pylance"
}

image

loserlulin9 commented 1 week ago

I have solved this bug by deleting the .vscode-server folder and redownloading all extensions. Thanks!!!